Retry Call to Web Service
- Home
- Neuron ESB
- Development
- Samples and Walkthroughs
- Process Samples
- Retry Call to Web Service
Overview
This sample demonstrates the Service and Retry Neuron Process steps. One of the components available in the Neuron Process step collection is a Retry process step that can be used to wrap a Service process step in retry logic to help overcome issues that may occur while calling the web service defined in the Service process step. The Retry step can detect either Communication or System.Exception errors and execute its contained steps a user configured number of times.
Process Components Demonstrated:
- Retry
- Service
- Code
- Trace
Solution
The Retry Service process depicted in Figure 2 has a Retry process step containing a Code process step name “set search name” and a Service process step. The set search name step will be used to set the message content. In order to demonstrate the Retry step we need some means of forcing a timeout to occur in the communication between the process and the actual web service defined in the Service process step. The “set search name” step along with the test service will help us accomplish that. The set search name Code step will create the message sent to the service. With each retry, the message content will be changed. The sample WCF service is configured to “sleep” for any request that it finds invalid. The “sleep” will cause a timeout to occur in the Service process step. On the 3rd attempt, the Code step will send a valid message and the process will “break out” of the Retry step.
The Retry step is configured to trace error messages so this sample will use the Test feature built into the Neuron Process Designer. Testing in the designer allows you to see each step being executed. Trace messages can be seen in the designer’s Trace Window during testing.
The final step in the process is a Trace step. This step will be used to display the resulting message in the Process Designer’s Trace Window from the WCF service called by the Service process step.
Test Service Solution
The sample WCF service used in the example can be found in the Samples\Processes\RetryWebServiceCall\ServiceProcessService folder under the main Neuron installation folder. The Visual Studio solution is named “ServiceProcessService.sln” and was built with Visual Studio 2008.
The service has one exposed method that accepts a string “name” and returns a Person object. The Person object collection is seeded with 3 default items. When the method is called it checks the name against one in its list. If found it returns immediately. If not found the method “sleeps” for 5 seconds before returning. This behavior will be used to help demonstrate the Retry process step in this example.
Running the Sample
Open the Sample
To open this sample, see the topic Using the Neuron Samples and select the Retry Web Service Call sample.
Setup Instructions
Before running this sample, follow these instructions:
- In the Visual Studio project that opens, build the solution.
Run the Sample
- Navigate to the Process Designer by selecting the Processes tab in the left panel of Neuron Explorer.
- Select the Retry Service process from the list on the left of the designer.
Note: Maximize Neuron Explorer and drag the process to the left of the designer so that the trace message will be easier to view on the designer as the process runs. - On the Process Designer toolbar click the Test button . This will open the Edit Test Message Dialog shown in Figure 3.
- Click the OK button on the Edit Test Message dialog. Once the dialog is closed the process will begin execution.
- As the process runs each step will be highlight in green as it is executed. As you visually follow the execution, note the sequence of steps. Also note the trace errors that are displayed in the Trace Window by the Retry step when the Service step fails to execute properly. The errors should be visible and be similar to that shown in Figure 4.
- As the process runs note that on the 3rd attempt the Service call is successful and execution of the process continues to the Trace step where the final message is displayed on the designer surface.
Configuration Notes
All processes with the exception of the Code process step are configured by selecting and setting their properties in the property grid located at the bottom right of the process designer. The Code process step is configured by selecting the “Edit” option from the short cut menu that is available when right-clicking the Code step in the process designer. See the process documentation for more information.