In this blog post we are going look at how to manage routing in the new Azure ServiceBus EAI CTP.
As a scenario, I’m going to send a request for information (RFI) to some of my fellow MVP’s. To do that, I’m going to create a One-Way Xml Bridge, to receive the messages. After receiving the RFI message I tend to route it to one of three queues.
1. Create a ServiceBus project
Open Visual Studio 2010, and select Create Project. In the list of project templates, select ServiceBus, and Enterprise Application Integration. Give it a name and click Ok.
2. Create a Message Type
Right-click the project and select Add->New Item. At this time there are two types of artifacts you can add; Schemas and Maps. Select Schema and sett an appropriate name. In my case I set the name to RFI.xsd. Continue building up your schema. Notice, you don’t have to promote any nodes as you’d have to do in BizTalk.
3. Designing the Bridge
Double-click the BridgeConfiguration.bcs and drag a Xml One-Way Bridge from the toolbox to the canvas. This is going to be your entry point to your process, similar to a Receive Location in BizTalk. Set the name appropriately, and notice the Router Address which is going to be your endpoint in Azure ServiceBus.
4. Add Queues
As stated before, the incoming RFI message is going to be routed to any of the three queues. You might not your message relayed to a queue, and could there for use any of the other Destinations such as Relay– or External Service EndPoints. Either way, the principle of routing is the same.
Connect the Bridge with all Destinations.
5. Configure the Bridge
Next we’ll define the incoming message type(s). Double-click your Bridge (ReceiveRFI in my case). Click the plus button in the Message Types stage. Select the Message Type you created earlier, and click the arrow button on the right.
6. Enrich the Message
This is the interesting step, where we are going to promote some fields in the payload so that we can route on these in the next step.
First open your schema and select the node you care to use for routing (in my case Receive). Copy the Instance XPath from the Property window.
Then double-click the Bridge, select either of the Enrich stages, and then click the Property Definition button in the Property window. There are two Enrich stages, as you might be using a Transformation, in which case you might want to promote fields from either the original message or the transformed message.
For more information about transformations, have a look at Kent’s post.
Set the Type to XPath, and paste the XPath expression in the Identifier text box. Select the Message Type and set the name of the property. Finish be setting the data type and click the Add button (+). Close the dialog by clicking the Ok button.
7. Set the routing conditions
As you have promoted your property (or properties), you’re now ready to set the Filter Conditions on each of the Connectors. Select one of the selectors and type the Filter in the Property window. Eg. receiver=’SteefJan’ or customerId=1234.
8. Create the Queues
Before we deploy the solution, you need to create the queues. There are several tools for this, but with the samples comes a MessageReceiver project you can use.
Type MessageReceiver.exe <Your namespace> owner <Your issuer key> <Queue name> Create
After creating the queues verify they are created in the portal.
9. Deploy your solution
Right-click the project and select Deploy. Supply the secret.
10. Test the solution
Along with the MessageReceiver tool, you’ll find a MessageSender project as well. Just type:
MessageSender.exe <Your namespace> <Your issuer key> <Your endpoint> <Path to sample file> application/xml
Use the MessgeReceiver to get the messages from the queues:
Blog Post by: wmmihaa