ServiceMix allows for different message dispatch policies within the Normalized Message Router (NMR) Broker.
There are four basic types:
Straight-through (ST) Flow
A MessageExchange is routed straight to it's destination with no staging or buffering. A straight through flow is best suited for the cases where the ServiceMix JBI container is deployed with simple flows (no state) or embedded, or where latency needs to be as low as possible.
Panel |
---|
borderColor | #ccc |
---|
title | ST Flow |
---|
borderStyle | solid |
---|
|
![](/confluence/download/attachments/39155/stflow.jpg?version=1&modificationDate=1171443075000&api=v2)
|
Seda Flow
The Seda flow introduces a simple event staging between the internal processes in the NMR Broker. A Seda flow, which is the default flow used by most components, is suited for general deployment. The additional staging is well suited buffering exchanges between heavily routed to components (where state may be being used) for example.
Panel |
---|
borderColor | #ccc |
---|
title | Seda Flow |
---|
borderStyle | solid |
---|
|
![](/confluence/download/attachments/39155/sedaflow.jpg?version=1&modificationDate=1171443075000&api=v2)
|
JMS Flow
A JMS flow is used for cases where you need collaboration between more than one ServiceMix JBI container. For example, an application that needs to have fail-over capability or an application that needs to balance its endpoints among several machines would need to have one or more JBI containers working in concert.
When JBI containers are deployed in a cluster, component deployment happens in the same way as a normal, but all the containers in the cluster are notified of a deployment, and the JMS flow handles automatic routing and failover of MessageExchange(s) between the container instances.
A Message Queue is used for each JBI endpoint, so multiple instances of the same named Component will have requests load balanced across them.
Panel |
---|
borderColor | #ccc |
---|
title | JMS Flow |
---|
borderStyle | solid |
---|
|
![](/confluence/download/attachments/39155/clusterflow.jpg?version=1&modificationDate=1171443075000&api=v2)
|
JCA Flow
The JCA flow is very similar to the JMS flow. It allows users to cluster ServiceMix containers together.
The main difference is that it uses JCA to provide support for XA transactions when sending and receiving
JBI exchanges. You can find more informations on transactions here.
Configuring flows
In versions of ServiceMix prior to 3.3 Flows were configured on the JBI container by using the flowNames attribute on the sm:container
element.
Code Block |
---|
|
<sm:container flowNames="seda">
...
</sm:container>
|
JMS and JCA flows should be configured with an ActiveMQ url to the broker.
Code Block |
---|
|
<sm:container flowNames="jms?jmsURL=tcp://localhost:61616">
...
</sm:container>
|
You can define several flows by using a comma separated list.
Code Block |
---|
|
<sm:container flowNames="seda,jms?jmsURL=tcp://localhost:61616">
...
</sm:container>
|
For more complex configuration, you define the flow explicitly. This method is also the recommend method for configuring flows in ServiceMix 3.3 and later.
Code Block |
---|
|
<sm:container>
<sm:flows>
<sm:sedaFlow />
<sm:jcaFlow bootstrapContext="#bootstrapContext"
connectionManager="#connectionManager"
jmsURL="vm://localhost" />
<sm:jmsFlow jmsURL="tcp://localhost:61616" />
</sm:flows>
</sm:container>
|
See also: How Stuff Works