Skip to content

Request-Reply Workflow

Note: It is recommended that the Neuron process documentation be reviewed before running this sample. The documentation thoroughly describes each process component individually and describes how to configure each one as well as how to construct a process and associate it with a Neuron Publisher or Subscriber. See the Configuration Notes section at the end of this document for more information.

Overview

There are three basic types of workflows: Normal, Request-Reply and Correlated. This sample shows a Request-Reply workflow that accepts a promotion code on the text property of the incoming ESBMessage and replies with a new ESBMessage where the text property contains the discount corresponding to the promotion code. A Request-Reply workflow is executed once for each message sent to the topic associated with the Workflow Endpoint.

Running the Sample

Open the Sample

This sample contains a Neuron ESB Configuration as well as this documentation page. To open this sample, see the topic Using the Neuron Samples and select the Request-Reply Workflow sample. This sample requires a configured SQL Server database. See the topic Configuring a Database for the Workflow Samples to setup the database. Don’t forget to start the Neuron ESB Service after configuring the database!

Open the Workflow in Neuron ESB Explorer

Click the Processes tab and double-click the RequestDiscountWorkflow item to show the workflow in the Workflow Designer:

This workflow includes the following Arguments:

  • request – the incoming message sent on the topic
  • reply – the outgoing message
  • configuration – access to components of the solution including XML and XML documents
  • environmentVariables – all environment variables defined in the solution

The workflow defines the following variables (click on the Flowchart activity to view these variables):

  • promoCode – the promotion code passed in the text property of the incoming ESBMessage (i.e. request.Text)
  • discount – the discount value returned in the text property of the outgoing ESBMessage (i.e. reply.Text)

This workflow uses the flowchart layout.

  1. The StartNode activity is the entry point into the workflow.
  2. The CSharpCodeActivity parses the incoming request text, converts it to upper case and assigns it to the promoCode variable. To view the code window, select the Parse Request Message activity and click on the ellipsis for the Source Code property:
  1. The first WriteLine activity logs the text to the Output panel in Neuron Explorer while testing and to the log file while executed through the Neuron Test Client and other clients.
  2. The FlowSwitch activity is configured with promoCode as the expression and will branch to a particular Assign activity based on if the value is “GOLD”, “SILVER”, “BRONZE” or anything else.
  3. Each Assign activity sets the discount variable to a particular Double value.
  4. All Assign activities flow into the CreateReplyMessage activity which takes the incoming request argument and creates a new message based on that message. The new message is assigned to the reply argument.
  5. The next Assign activity sets the reply.Text property to the value of the discount variable.
  6. The final WriteLine activity logs the discount value.
Note: When testing the workflow in Neuron Explorer, all WriteLine activities will log to the Output panel. When the workflow is executing in the Availability Group child process of the ESB Service then the log entries are written to the Availability Group log (ex: C:\Program Files\Neudesic\Neuron ESB v3\logs\DEFAULT\20141024T135818\MTUCKER03_Enterprise_Availability Group_NormalWorkflowAvailabilityGroup-2014-10-24.log)

Test the Workflow in Neuron Explorer

You should still be in the Workflow Designer.

  1. To run the workflow, click the Test Workflow button on the toolbar
  2. On the Edit Test Message dialog, enter a text value for the message body (ex: gold, silver, bronze, or copper)
  1. Click the OK button.
  2. The Workflow Designer will show the running workflow by highlighting the currently executing activity in yellow:
  1. The Output panel shows the results:

Executing the Workflow

  1. Open an instance of the Neuron Test Client and connect using the DiscountPublisher:
  1. On the Send tab enter a text message, set the Semantic to Request and click the Send button:
  1. On the Receive tab you will see the response discount code:
  1. In Neuron Explorer click the Activity tab and then on Workflow Tracking
  2. Click on the Run Report button and you will see that one workflow has executed and is in the Completed state:

For every message you send using the Neuron Test Client, a new workflow instance entry will display in the Workflow Tracking screen.

Was this article helpful?
Dislike 0
Previous: Normal Workflow
Next: Correlated Workflow