Exploring the Service Bus Relay, Queues,Topics and Subscriptions with Visual Studio 2012 RC and Windows Azure SDK 1.7

 

Introduction

In my post on Future BizTalk Server Release and Microsoft Integration Strategy I discussed the three pronged Microsoft integration strategy:
  • On-premise BizTalk (a CTP of next version will be released this summer)
  • BizTalk IaaS (Infrastructure as a Services), Windows Azure offers services like Virtual Machine and Virtual Network to enable to have your BizTalk infrastructure in the cloud;
  • BizTalk PaaS (Platform as a Services) with EDI/EAI integration capabilities using the Service Bus.
In this post I like to share my exploration of the Windows Azure Service Bus. My focus is on BizTalk professionals that do not yet have much experience/knowledge of the Windows Azure Service Bus.Two sessions by Clemens Vasters from last TechEd North America were my baseline before I started my exploration:
I will explore capabilities of Queues, Topics and the Relay as depicted in overview below of the Service Bus.

image

In picture above you see different solutions, devices that through services bus communicate with Line of Business applications (SAP, Oracle E-Business Suite), SharePoint and many other systems and applications.

The Windows Azure Service Bus offers capabilities that allow you to create solutions in the cloud that are based on message-oriented-middleware technologies including reliable message queuing and durable publish/subscribe messaging. Ergo its is a messaging infrastructure in the cloud. This means that Service Bus can act as a broker for asynchronous messaging (decoupling). Therefor this infrastructure can support publish-subscribe, temporal decoupling, and load balancing scenarios similar to BizTalk Server. Queues, Topics and Subscriptions are services (entities) of the Service Bus that provide durable, asynchronous messaging.

Relay is an entity that allows you to pass-through message (relay) from one system/application to another. Relay service that sits in Service Bus brings the ability to securely expose Windows Communication Foundation (WCF) services (even orchestrations or LoB Services) that reside within your enterprise network to the public cloud, without having to open up a firewall connection or requiring intrusive changes to your enterprise network infrastructure.

Note: Notifications topics and bridges are services (entities) in Service Bus that will be available later and are currently not present.


Get started


To get started I created a new VM with Windows Server 2008 R2 with Visual Studio 2012 RC and Windows Azure SDK 1.7. Now the SDK can also be used with Visual Studio 2010 SP1. You can use either VS2010 or VS2012 with this SDK.

Samples


The sample on the relay is a 101 sample on using the Relay. The other sample is more a walkthrough, using Queues, Topics and Subscriptions in the service bus by using the Service Bus Explorer. There illustrative to show the capabilities of these services if you are not familiar with them. You’ll need either Visual Studio 2010 SP1 or Visual Studio 2012 RC, Windows Azure SDK 1.7 (June 2012) and a namespace in Service Bus. Relay samples in this post and the walkthrough with the Service Bus Explorer is done in Visual Studio 2012 RC.

Create a namespace


To create a service namespace:
  • Log on to the Windows Azure Management Portal. If you end up in the new portal then select preview and choose Take me to the previous portal (Managing the Service Bus is still done in the old portal).
  • In the lower left navigation pane of the Management Portal, click Service Bus, Access Control & Caching.
  • In the upper left pane of the Management Portal, click the Service Bus node, then click the New button.
  • In the Create a new Service Namespace dialog box, enter a Namespace, and then to make sure that it is unique, click the Check Availability button.
  • After making sure the namespace name is available, choose the country or region in which your namespace should be hosted (make sure you use the same Country/Region in which you are deploying your compute resources), and then click the Create Namespace button.
  • The namespace you created will then appear in the Management Portal and takes a moment to activate. Wait until the status is Active before continuing.



Service Bus NuGet Package


The Service Bus NuGet package is the easiest way to get the Service Bus API and to configure your application with all of the Service Bus dependencies. The NuGet Visual Studio extension makes it easy to install and update libraries and tools in Visual Studio and Visual Web Developer. The Service Bus NuGet package is the easiest way to get the Service Bus API and to configure your application with all of the Service Bus dependencies.
To install the NuGet package in your application, do the following:
  • In Solution Explorer, right-click References, then click Manage NuGet Packages.
image
  • Search for "WindowsAzure.ServiceBus" and select the Windows Azure Service Bus item. Click Install to complete the installation, then close this dialog.
image

Building a SIMPLE Relay Sample


To build a sample that will make use of relay service you need to create a WCF-service. The following steps show how to build a very basic service that can be exposed in the Service Bus.
  • Within Visual Studio, create a console application
  • Add the Windows Azure Service Bus NuGet package to the projects. This adds all of the necessary assembly references to your projects.
  • Add a class to project and give it a descriptive name.
  • Rename the class to HelloRelayContract and then implement code like below:
image
  • Add a new class to the project and rename it HelloRelay and then implement code like below:
image
  • In program.cs implement the following code:
image
  • In order to perform management operations, such as creating a relay connection, on the new namespace, you need to obtain the management credentials for the namespace.
  • Select the namespace you just created from the list show below:
image
  • The Properties pane on the right side will list the properties for the new namespace:
image
  • The Default Key is hidden. Click the View button to display the security credentials:
image
  • Open app.config and make the appropriate adjustments like below:
image
  • You can past the default key in the issuerSecret attribute.
  • Now that you have build and configured the service you can run the console application that will act as host for the service.
image
  • Copy the address in your browser and you will get result like below:
image

Service Bus Explorer


One of new tools available through the SDK is the Service Bus Explorer. With the SDK installed you have access to several Azure features from Server Explorer.
image
To access the service bus through the Server Explorer:
  • Right click the Windows Azure Service Bus.
  • Select add new connection.
  • Fill in the namespace, Issuer Name and Issuer Key.
image
  • Click Ok
  • You now have access to Service Bus
image

QUEUES, TOPICS AND SUBSCRIPTIONS USING THE SERVICE BUS EXPLORER


To build a sample that will make use of queues, topics and subscriptions. These services support brokered messages. With the service explorer I can manage the service bus without using the portal (see previous paragraph). You can create queues through code or through using the explorer. Using the explorer you can right click Queues and add a new Queue.

image

Fill in a name, change some the values if necessary, click options and click Ok. You will then see your queue in Service Explorer.

image

You can right click the created queue and select Send Test a Message. You will then see dialog pop up with the message.

image

You will notice in the properties of the queue that the message count is 1.

image

With topics you can do the same. Right click topics and select Create New Topic….

image

Fill in a name, change some the values if necessary, click options and click Ok. You will then see your topic in Service Explorer.

image

Before you can send a message to the topic you need to create a subscription. Select subscriptions and right click. Select Create New Subscription ….

image

Fill in a name, change some the values if necessary, click options and click Ok. You will then see your topic in Service Explorer.

image

Like queues you can send a test message through the topic.You can right click the created topic and select Send Test a Message. You will then see dialog pop up with the message. In subscription properties you will see message count is 1.

image

On the subscription you can right click and select Receive Message. A dialog will pop up with the message.

image

Now you can create more subscriptions in the topic and then sent a test message. You will then see that both subscriptions in the topic will have that message. Now you can use rules to determine, which subscription will get which message. This is new functionality with topics and subscriptions. You can within a subscription add a rule. Open the desired subscription and right click rules. Select Create New Rule…. A dialog will appear.

image

Give it a name and add a Sql Filter Expression. Click Ok. You now have created a rule on the subscription.

Note: The Overview and Roadmap of Windows Azure Service Bus session of Teched NA will provide more context on Service Bus explorer. It will also demo using queues and topics with new Worker Role with Service Bus template.

Call to action


To learn more besides the two sessions from TechEd I suggest to look at Developing Applications that Use the Service Bus on MSDN, Alan Smith’s Developers Guide to AppFabric and resources listed below:
Update: Thanks to Paolo Salvatori I have been pointed some of the articles and samples he wrote on the Service Bus:
I myself got a little more feeling now with the new SDK and some of its features. My experience with the Service Bus explorer within Visual Studio 2012 RC so far has been great. It works seamlessly and is straight forward. Enjoy your own exploration!

Cheers,

- Steef-Jan

Comments

Popular posts from this blog

DTAP Strategy: Pricing and Licensing

Table Operation on Oracle 11g XE with OracleDbBinding

Integration, the community blasting into 2017!