Quantcast
Channel: Enterprise – Rock – Paper – Scissors – Cloud!
Viewing all articles
Browse latest Browse all 10

Enterprise Integration Patterns with Service Bus (Part 1)

$
0
0

Last week I presented at TechReady a session titled: Achieving Enterprise Integration Patterns with Service Bus. Folks who are familiar with the work of Gregor Hohpe, and the book / site http://www.eaipatterns.com/ already know the power of these building blocks in solving integration problems. I will not cover all the material in detail here but wanted to share the key concepts that enable the use of Windows Azure Service Bus in implementing these patterns. As the title of this post indicates, this is a first step of many and here I will cover the following:

  1. Messaging Channel Pattern
    • Publish-Subscribe
    • Content based routing
    • Recipient List

 

Publish-Subscribe

The scenario here is that a sender broadcasts an event to all interested receivers. A common use cases for this is event notification.

The way to implement this with Service Bus is to have a Topic with several Subscriptions. Each Subscription is for a recipient of the event notification. A single message sent to the Topic will be delivered to each Subscription (each will receive a copy of the message)

image

Some key features of Service Bus relevant to this pattern:

  1. A single Topic can have up-to 2000 Subscriptions
  2. Subscription can be individually managed with permissions
  3. Once a Subscription is created, it gets all subsequent messages sent to the topic
  4. Reliable delivery can be achieve thru PeekLock and Transactions

The code sample for this is available here.

Content based Routing

This is when we want to route a message to different recipients based on data contained in the message. The sender is not aware of the specific recipients but just sets appropriate metadata in the message. The recipients decide if a message is relevant to them based on its content.

Any scenario where you need to perform a single logical operation across different systems would need this, say an order processing system that routes orders to different departments.

The Service Bus implementation for this is thru use of SQL Rules on Subscriptions. These Rules contain Filters that are applied on the properties of the message and determine if a particular message is relevant to that Subscription.

image

Service Bus Features used:

  1. SQL Filters can specify Rules in SQL 92 syntax
  2. Typically Subscriptions have one Rule but multiple can be applied
  3. Rules can contain Actions that may modify the message (in that case a copy of the message is created by each Rule that modifies it)
  4. Actions can be specified in SQL 92 syntax too.

The code for this sample is available here.

Recipient List

There are scenarios where a sender wants to address a message to specific recipients. Here the sender sets metadata on the message that routes the message to specific subscribers.

Common use cases for this are order processing systems where the order needs to be fulfilled by a specific vendor or department that is selected by the user submitting the order. Email is another such messaging pattern.

The Service Bus implementation for this is thru use of SQL Rules on Subscriptions. We use the LIKE clause in SQL filters to achieve the desired results. The sender can just add the addresses of recipients in a comma-separated manner.

image

Service Bus Features used:

  1. SQL Filters with Rules in SQL 92 syntax
  2. LIKE clause for finding items addressed to Recipient
  3. Comma separated values to address multiple recipients

The code for this sample is available here.

Happy messaging!



Viewing all articles
Browse latest Browse all 10

Trending Articles