Skip to content

Failed Message Routing

Overview

Failed message processing is a convenient method to notify Neuron Administrators and Operators when messages have been written in the Failed Message table of the Neuron Audit Database. Messages can be written there for a variety of reason. Sometimes they are written by Audit steps in Processes. Other times Neuron automatically writes them there because there was an error when sending the message to an external system. Regardless of how they end up there, having a convenient method for notifying operators that they exist is important.

Solution

This solution requires an ODBC Adapter endpoint and an Smtp Adapter endpoint. The ODBC Adapter endpoint is configured to poll a stored procedure called GetFailedMessagesForProcessing. This stored procedure will check the table MessageAudit_Fail for new failed messages. When it finds one, it publishes that message to the ESB and then adds the MessageID of the failed message to the table MESSAGEAUDIT_PROCESSED, which it uses to track which failed messages have been published. The published messages are subscribed to by the Smtp Adapter endpoint which sends a notification to the configured To: email addresses.

Consider using this logic for all of your Neuron ESB Solutions.

Running the Sample

Prerequisites

  1. To run this sample you must have access to an Smtp server.

Open the Sample

To open this sample, see the topic Using the Neuron Samples and select the Failed Message Routing sample.

Configure the Neuron Auditing Database

This sample requires a Neuron Auditing Database to be configured. The sample already has a database configured – you will need to either create the database on the localhost or on a remote SQL Server:

  1. In the Neuron ESB Explorer, navigate to Deployment->Manage->Databases.
  2. Select the database NeuronAuditDB.
  3. If necessary, modify the value in the Server text box and then click the Test/Create Database button.
  4. Click the Security tab. The NT AUTHORITY/SYSTEM account has been added. If you configured the Neuron ESB runtime to use a different account, add that account here now..
  5. Click the Apply button.
  6. If you changed the Database name, you need to navigate to Deployment Groups and select the Dev deployment group. Select your database from the dropdown list and click Apply. Save the solution.

Configure Adapter Endpoints

The adapter endpoints used in this sample use Environment Variables for setting the critical properties.

ODBC Adapter Endpoints

You’ll need to verify the ODBC Adapter endpoint environment variables:

  1. In the Neuron ESB Explorer, navigate to Deployment->Environments->Environment Variables.
  2. Select the environment variable NeuronAuditDatabaseOdbcConnectionString, and verify the value is valid for your Neuron Auditing database.
  3. After modifying the environment variable, click the Apply button and save the solution.
The Environment Variables screen
Figure 1: The Environment Variables screen

Smtp Adapter Endpoints

The Smtp adapter endpoint is configured to use environment variables for the To:, From: and Server adapter endpoint properties. You’ll need to verify these environment variables. Note: If your Smtp Server does not use the default port value of 25, you will need to modify that adapter endpoint property directly.

  1. In the Neuron ESB Explorer, navigate to Deployment->Environments->Environment Variables.
  2. Select the environment variable SmtpAlertServer, and verify the value is valid for your Smtp Server.
  3. After modifying the environment variable, click the Apply button.
  4. Repeat steps 1-3 for the SmtpAlertFromAddress and SmtpAlertToAddress.
  5. Save the solution.
  6. Restart the Neuron ESB service.

Run the Sample

  1. Open a Neuron Test Client from Neuron ESB Explorer by clicking Tools->Test Client->1 Test Client. Connect it to the Party TestTopicPublisher. This party is configured to execute the process Force Message Failure, which will send every message it processes to the Failed Message Audit table.
  2. In the Test Client, click the Send tab and enter any data into the Message pane. Click the Send button.
  3. The Force Message Failure process will send the message to the failed message table, and the ODBC Adapter Endpoint will receive that message as it polls by calling the stored procedure GetFailedMessagesForProcessing and publishes the failed messages to the ESB.
The Force Message Failure process
Figure 2: The Force Message Failure process. The C# code step throws an exception and the audit step in the catch block records the message to the database.
  1. The Smtp Adapter Endpoint will receive the failed message and send it to the server and mailbox configured in the earlier steps. Open a mail client and connect to that server to see the message.
  2. The stored procedure called by the ODBC Adapter Endpoint will store the message ID of the failed message in the MESSAGEAUDIT_PROCESSED table to ensure that the same failed message is not sent twice.
  3. The table MESSAGEAUDIT_PROCESSED and stored procedure GetFailedMessagesForProcessing are included with the Neuron Audit Database and do not need to be manually created.
Was this article helpful?
Dislike 0
Previous: Scatter Gather Pattern
Next: Publish/Subscribe