Thursday, August 12, 2010

Hub & Spoke Vs WCF Routing

Hub & Spoke architecture style – When it comes to integration in heterogeneous environment, hub & spoke architecture style is the best and proven option. This architecture style can be realized through queues, messages & some routines. The different apps of an enterprise can communicate with each other through message exchanges.

Sometimes, the same architecture style is also used for just content based message routing. Some people call it as ‘message based integration’. Messages will have different values in headers indicating their type & other details. Based on the content in the header, each message will be routed through different paths. Message processing will be taken care by routines or batch processes.

With the availability of the options like WCF Router in .Net 4.0, it has now become a must to find when exactly to use hub & spoke. Using it in simple places like content based routing will make things complex. While options like WCF Routing is available, hub & spoke should not be employed unless there is a definite need.

Let us see the candidate scenarios where hub & spoke could be the best solution:

  1. When there is a need for asynchronous, content based routing. Here, queues will be used to persist the messages so that they can be processed later by the routines asynchronously
  2. When reliability & transaction takes high priority, then obviously message based solution scores higher no. of points (by saying that I does not mean that WCF Routing is unreliable)

WCF Routing scores high when it comes to synchronous content based routing. Why? Because it is simple when it comes to effort required for implementing a solution. Also, it makes things easy when to compared to hub & spoke.

When it comes to implementation, following are the building blocks that will be used in hub & spoke:

Queue –It will be used as a place for persisting messages temporarily; MSMQ, MQ Series etc.

Messages – XML messages in pre-defined formats; Header attributes will indicate what the
message is meant for ; say like invoice, order, delivery note etc.

Routines / Listeners – Windows services which will be configured to watch various queues and process the messages based on the header values. Say invoice processing windows service will look for the messages with “Invoice” in the “Transaction” attribute in the header and process it

In some cases, even databases are used instead of queues as they also offer the same benefits as what queues offers in terms of transaction, security, durability etc.

Even though hub & spoke architecture style enables heterogeneous integration with loose coupling, using of components like queues & windows services will make implementation more complex. Also, as no of transaction types increase, routines are to be developed and deployed to do processing.  

Even though WCF Router does not have any persistent capability, it can also attribute to reliability to certain extent through its support for increasing fault tolerance by routing traffic away from unavailable services.

You can think why I am comparing Apple with an Orange! I had compared here a technology option with an architecture style. But I had done it from the perspective of the problem – “content based routing”.