Share via


How to use Business Rules in the ESB Toolkit and test them with the BRE TestTool

Introduction

In the ESB toolkit for BizTalk Business Rules can be used in the following scenarios:

  • Dynamic routing
    • Dynamically routes a message, based on the content of a known message type
  • Dynamic transformation
    • Dynamically transform a message from one type to another, based on the content of a known message type
  • Specifying Itineraries
    • Select an itinerary based on the content of a received message

It is not very difficult to create business rules policies in the Business Rule Composer that can be used for one of these scenarios but is not so easy to test the created policies because it’s not documented how to do it. You have to find out which specific classes, properties and methods are used and in which DLL libraries they are located. So I made a sample tool with which these ESB Toolkit classes can be tested!

Using the Tool

With the sample Tool policies can be tested that have one of the following vocabularies from the ESB Toolkit:

  • ESB.EndPointInfo
    • Set the Outbound Transport Location properties of a Send Port.
  • ESB.TransformInfo
    • Set the Transform Type.
  • ESB.Itinerary
    • Set the Itinerary Name.

Specifying Itineraries

How to dynamically select an itinerary based on the content of a received message and how to test it.
 

Create a Policy with Business Rules which select an itinerary

Create a Policy with the specific Business Rules in the Business Rule Composer which select an itinerary.


Figure 1. Microsoft Business Rule Composer.
This example is based on: How to Select an Itinerary Using a Business Rules Policy
 

Using the Policy in a Receive Location

Configure the Itinerary Selector pipeline component in a Receive Location to use a business rules policy to select the appropriate itinerary.


Figure 2. Specify pipeline properties.
 

How to test the Policy

Open the XML file in the TestTool and specify the following properties:

  • Select the “ESB.Itinerary” Fact.
  • Select the name of the Business Rules Policy with the PolicyPicker
  • Enter the Document Type of the message.


Figure 3. Specify the policy.
 Now you can test the policy.



Figure 4. ESB Toolkit 2.2 Business Rule Tester.
 

When you click on the “Test” button, the policy is executed against the BRE engine.

  • The trace output of the BRE engine is displayed on the Trace tab.
  • The Action tab is automatically selected and shown when the test result of one of the rules is true.
  • The tool tests if the itinerary exists in the Itinerary Store database.
    • When this is the case it is shown in the Tool otherwise you get a warning message.


Figure 5. Test output of ESB Toolkit 2.2 Business Rule Tester.
On the Trace tab are the Test results of the BRE engine displayed. On the Actions tab the resolved itinerary name. The resolved itinerary is displayed on the Itinerary tab.
 

Dynamic Transformation

How to dynamically select a map based on the content of a message and how to test it.
 

Create a Policy with Business Rules which select the map

Create a Policy with the specific Business Rules in the Business Rule Composer which select the map.


Figure 6. Business Rule Composer select map.
 

Using the Policy in an Itinerary

Configure the properties of the Resolver to use a business rules policy to select the appropriate map.


Figure 7. Configure the properties of the Resolver.
 

How to test the Policy

Open the XML file in the TestTool and specify the following properties:

  • Select the “ESB.TransformInfo” Fact.
  • Enter the name of the Policy in containing the Business Rules.
  • Enter the Document Type of the message.
 

When you click on the “Test” button, the policy is executed against the BRE engine.

  • The trace output of the BRE engine is displayed on the Trace tab.
  • The Action tab is automatically selected and shown when the test result of one of the rules is true.
  • The tool tests if the Map exists in the GAC.
    • When this is the case it is executed and shown otherwise you get a warning message.


Figure 8. Testing the policy.
 

Dynamic Routing

How to dynamically select a destination based on the content of a message and how to test it.
 

Create a Policy with Business Rules which select the destination

Create a Policy with the specific Business Rules in the Business Rule Composer which select the destination.


Figure 9. Create a policy in Business Rule Composer.
This example is based on: How to Implement Content-Based Routing Using a Business Rules Policy for a Known Message Type
 

Using the Policy in an Itinerary

Configure the properties of the Resolver to use a business rules policy to select the appropriate destination.


Figure 10. Configure the properties of the Resolver.
 

How to test the Policy

Open the XML file in the TestTool and specify the following properties:

  • Select the “ESB.EndPointInfo” Fact.
  • Enter the name of the Policy in containing the Business Rules.
  • Enter the Document Type of the message.


Figure 11. Testing the policy.
 
 

Downloads

You can download the sample tool with the source code here:
Testing Business Rules in ESB toolkit 2.1 for BizTalk 2010
Testing Business Rules in ESB toolkit 2.2 for BizTalk 2013

See Also

Read suggested related topics:

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.