Sunday, February 9, 2014

Message routing over an ESB

How is the routing done over the ESB / bus?

Routing configuration can be available on the client or on the bus and can be changed during runtime.
Certain bus products allow you to configure routing of messaging by using a DSL. 
Here is an example:

from("invoices").choise().when(header("invoiceType").isEqualTo("clearing")
.to("clearingQueue")
.otherwise("costcenterQueue")

This shows a content-based routing. Depending on a meta data the message from one queue is routed to one of other 2 queues.

Further example with Camel:

For routing purpose we take a quick at Camel.
Camel is an integration platform, a framework with the target to provide EIP based components.
Is Camel itself already an ESB? As there is no standard definition, the answer is yes and no.
But the core functionality it brings is definitely  a routing and transformation engine.
Routes are defined in Camel with XML configuration or a DSL like above.
The messages are collected at the endpoints and processed through the defined routes.
A route itself contains of flow and integration logic. 
A message always has a producer and a consumer - inside the Camel context (runtime system of Camel)
there are processors that processes the message further by filtering, enriching, routing, transforming etc.
The component inside Camel that manages these processing that happens between the service provider and consumer
is called MEC (Message Exchange Container). This component has further information about the unique message ID, exception information, etc.

The routes are defined or to be more explicit are added to the Camel context.
This runtime system brings all the defined components in Camel together.
A route definition is a plain Java class that needs to extends RouteBuilder and needs to implement the configure-method.
In here the route must start with from(…) and end with to(…).

Like in the above snippet all the processing logic happens besides these two points.

No comments:

Post a Comment