Home > BizTalk, BizTalk ESB ToolKit, Visual Studio > Implementation of Routing slip pattern using ESB Toolkit 2.1 and BizTalk Server 2010

Implementation of Routing slip pattern using ESB Toolkit 2.1 and BizTalk Server 2010

Routing slip pattern describes a scenario where we route a message consecutively through a series of processing steps when the sequence of steps is not known at design-time and may vary for each message.

Business Case: XML messages pertaining to Employee schema are picked by BizTalk from a specified file location and routed through a series of processing steps (Itinerary) based on the value of department. For example if the department is ‘Admin’ then ‘ForAdmin’ itinerary will be selected and if ‘HR’ then ‘ForHR’ itinerary will be selected.

Solution Walkthrough:
This solution consists of following artifacts:
• Itineraries( ForHR.itinerary and ForAdmin.itinerary) – Series of processing steps defined for HR and Admin employees respectively.
• Business rule policy (SelectItineraryBasedOnDept) – Used to select the correct itinerary based on the value of department.
• XML Schema( Employee.xsd)

Steps to create and test the solution
1. Open BizTalk Administrator console and create an application named “ESBSamples”. add a reference of the application “Microsoft.Practices.ESB” to the ESBSamples project.
Note:Microsoft.Practices.ESB is the default application for ESB related artifacts which get automatically created during the configuration of ESB Toolkit 2.1
2. Right click on Send ports under the application ESBSamples and Create a new dynamic one way send port named “DynamicSendToOutput”. Create the following filters as shown below:
3. Create a Receive port ESBSample.OnRamp.Itinerary and a Receive location named ESBSample.OnRamp.Itinerary.FILE and configure this as:
URI: C:\C#\Input\*.xml
Receive Pipeline: ItinerarySelectReceiveXml having ItineraryFactKey = Resolver.Itinerary
ResolverConnectionString = BRI:\\policy=SelectItineraryBasedOnDept;useMsg=true;recognizeMessageFormat=true;

Here SelectItineraryBasedOnDept is the name of the Business Rule Policy which we will be creating from step- (8)
4. Now open visual studio 2010, create a blank solution named “Abhijit.ESBSamples”.
5. Add an Empty BizTalk Server project named “Abhijit.ESBSamples.Demo2.Schemas” and a BizTalk ESB Itinerary Designer named “Abhijit.ESBSamples.Demo2.Itinerary”.
6. Right click on the schema project and add a schema named Employee.xsd having following fields as shown below in the image:
7. After signing the project deploy it to application named “ESBSamples” the one we have created in step-1.
Create the Business Rule Policy:
8. Now open Business Rule Composer and create a policy named “SelectItineraryBasedOnDept”
9. In the SelectItineraryBasedOnDept policy, right-click and Add New Rule. Name the rule to ”SelectAdminItinerary”.
10. In Facts Explorer, click the XML Schemas tab, right-click Schemas, and then click browse
to Employee.xsd under the folder C:\C#\Abhijit.ESBSamples\Abhijit.ESBSamples.Demo2.Schemas\ and open it.
11. In fact explorer, click on Employee.xsd and change the Document Type property to
12. In the Rule window, right-click Conditions, point to Predicates, and then click Equal.
13. From Facts Explorer, drag the Department element to the argument1 node under Conditions.
14. Click the argument2 node, and then type Admin.
15. From Facts Explorer, drag the Set Itinerary Name definition under the vocabulary ESB.Itinerary to Actions.
16. Click and then type ForAdmin to ‘‘.

Similarly add one more rule named “ForHR” having following Conditions and Actions
Rule: SelectHRItinerary
Abhijit.ESBSamples.Demo2.Schemas.Employee:/Employee/Department is equal to HR
Set Itinerary Name to ForHR.
17. Publish and deploy the policy to RuleEngine database.

Create the “ForAdmin” Itinerary
18. Now switch to Visual studio solution and right click on Abhijit.ESBSamples.Demo2.Itinerary project and add an Itinerary named “ForAdmin.Itinerary
19. Design the Itinerary as below:
Here first shape is the On-Ramp(RcvAdminEmployee) and for the properties of this refer the below image.
Last shape is the Off-Ramp(SndAdminEmployeeMsg) and for the properties of this shape refer the below image.
Other two middle shapes are Itinerary service, one is for Messaging Extender(SendToFile) and other is for off-Ramp Extender(SetDestinationInfo).
For the properties of SendToFile shape, refer the below image

And for the properties of the Static Resolver used in the Itinerary service, refer the below image.

For the properties of off-Ramp Extender(SetDestinationInfo), refer the below image

20. Now Right-Click on the Itinerary designer and click on validate. You might get an error with description: A X509 Certificate is required in the model property ‘EncryptionCertificate’ to encrypt any sensitive property in the designer.

To get rid of this error you need to set the value of ‘Require Encryption Certificate’ to false.

21. Set the model exporter of the Itinerary as Database Itinerary Exporter and Itinerary status as Deployed.

22. Right-Click on Itinerary designer and click on Export model to store the Itinerary into EsbItineraryDb database.

Create the “ForHR” itinerary
23. Design the Itinerary as below image
Configuration properties for each shape is similar to “ForAdmin” itinerary. Only difference is in value of the ‘Transport Location’ of the Static Resolver used in ‘SendToFile’ itinerary service.
Right-Click on Itinerary designer and click on Export model to store the Itinerary into EsbItineraryDb database.

Test the solution:
• Download and extract the Source Code file to the C:\ drive; this process will create the necessary directories to test the application.
• From the BizTalk administrator console under the application “ESBSamples” enable the Receive location and start the send port. You might need to change the Receive location and send locations as per your environment.
• Now drop the files from the folder “C:\C#\Sample\“ into “C:\C#\Input\ “ folder. If everything configured properly then you will see one file each in the locations “C:\C#\Output\HR\” and “C:\C#\Output\Admin\” based on the value of the department field of the input messages.

Download the SourceCode:
To download the code please Click here

Note:Change the extension of the file from .doc to .zip and extract it into your C: drive.

  1. MEL
    June 27, 2012 at 5:47 am

    Hi Abhijit
    again nice post!!. I `m learning/working with biztalk esb toolkit and i.m interesting in routing to diferent endpoints depending on schema content… Supose your schema represents departments instead od employees, and inside your department schema there are several employees (the department workers), I was trying to route to diferent folders if ANY of the employees is “John Smith”, it works if J. Smith is the LAST employee in a department, NOT if is the first, second… HOw can i do it ?. Is not posible to write rules like “If ANY of the employees … if ALL the employees ” os something like that??
    Another thing is that i was trying to use WCF services as endpoint instead of folders… i.m completely lost and crazy, have you got any example of this in your blog? I dont find any suitable in internet.
    Thank you.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: