Introduction

BizTalk Server 2013 Beta introduces the new SB-Messaging Adapter to send and receive message from the Windows Azure Service Bus entities like Queues, Topics, and Relays. If you want to sent a message to a Service Bus Queue in Windows Azure with the ESB Toolkit it will not work out of the box.

 

Modifying and Extending the BizTalk ESB Toolkit

There is no SB-Messaging adapter provider in the ESB Toolkit so to make it
work you will have to create a custom SB-Messaging adapter provider. Furthermore
is also a custom Routing Service needed. The Routing Service of the ESB Toolkit set’s all the necessary properties on the Dynamic Send Port but the Authentication Properties and the Brokered Message Properties from the SB-Messaging adapter have to be set on the message as context properties.

 

To create a custom SB-Messaging Adapter Provider 
1. Create an assembly that derives from the BaseAdapterProvider base class and contains a SetEndPoint method that sets the endpoint context properties of the message.
2. Register the adapter provider by adding it to the Esb.config configuration
file using an <adapterProvider> element.
3. Create a Manifest File for Custom Adapter Properties
When creating a custom adapter provider, you must also provide designer support for the adapter provider to those resolver extenders that display an endpoint configuration property.
4. Register the new assembly in the global assembly cache.

 

To create a Custom Itinerary Messaging Service
1. Create a custom routing service that is based on the RoutingService in the Microsoft.Practices.ESB.Itinerary.Services Assembly. I used Reflector to get the code from the RoutingService class.
2. Add extra code to set the URI for the Service Bus Access Control Service STS endpoint, the issuer name and the issuer key for the Service Bus namespace because the properties are not set on the adapter, but on the message as context properties. Also the Brokered Message Properties are set on the message as context properties.

C#
Edit|Remove
//Get EndpointConfig from Resolver 
string endpointConfig = resolverDictionary["Resolver.EndpointConfig"]; 
                 
//Split items 
string[] arr = endpointConfig.Split(new[] {'&'},StringSplitOptions.RemoveEmptyEntries); 
                 
Dictionary<string,string> endpointConfigItems = new Dictionary<string,string>(); 
 
//Get key value pairs 
for (int i=0;i<arr.Count();i++) 
{ 
    string key = arr[i].Substring(0, (arr[i].IndexOf('='))); 
    string value = arr[i].Substring(arr[i].IndexOf('=') + 1); 
 
    endpointConfigItems.Add(key,value); 
} 
 
//Set WCF-properties 
msg.Context.Write("IssuerName""http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties", endpointConfigItems["IssuerName"]); 
msg.Context.Write("IssuerSecret""http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties", endpointConfigItems["IssuerSecret"]); 
msg.Context.Write("StsUri""http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties", endpointConfigItems["StsUri"]); 
 
//Set BrokeredMessage-properties 
msg.Context.Write("Label""http://schemas.microsoft.com/BizTalk/2012/Adapter/BrokeredMessage-properties", endpointConfigItems["Label"]); 
            

 3. Register the Custom Itinerary Messaging Service by adding it to the Esb.config configuration file using an <itineraryService> element.
4. Register the new assembly in the global assembly cache.

More Information

For more information on using the SB-Messaging Adapter & ESB Toolkit to send messages to the Windows Azure Service Bus:

http://www.ithero.nl/post/2012/12/02/Using-the-SB-Messaging-Adapter-ESB-Toolkit-to-send-messages-to-the-Windows-Azure-Service-Bus.aspx