servicemix-eip
The servicemix-eip component is a routing container where different routing patterns can be deployed as service unit.
This component is based on the great Enterprise Integration Patterns book.
Supported patterns:
- Content-Based Router
- Message Filter
- Pipeline
- Static Recipient List
- Static Routing Slip
- Wire Tap
- XPath Splitter
- Aggregator
In addition, this component can use all ServiceMix flows (including clustered and transactional flows), can be configured to be resilient to crashes and supports full fail-over to another node when clustered.
Using servicemix-eip as a standard JBI component
Installation
Installing the servicemix-eip component can be done in several ways:
- drop the installer zip in an hotdeploy directory monitored by ServiceMix
- using ant tasks
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.
Configuration
TODO: configure a persistent / clustered store
Service Unit packaging
Content of xbean.xml file to be packaged as a SU
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns:eip="http://servicemix.apache.org/eip/1.0"> ... add eip patterns here ... </beans> |
Using servicemix-eip in a ServiceMix xml configuration file
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns:sm="http://servicemix.apache.org/config/1.0" xmlns:eip="http://servicemix.apache.org/eip/1.0"> <sm:container ...> <sm:activationSpecs> <sm:activationSpec> <sm:component> <eip:component> <eip:endpoints> ... add eip patterns here ... </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> ... </sm:activationSpecs> </sm:container> ... </beans> |
Patterns
Content-Based router
ContentBasedRouter can be used for all kind of content-based routing.
This pattern implements the Content-Based Router pattern.
Wiki Markup |
---|
{snippet:id=content-based-router|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
Message Filter
MessageFilter allows filtering incoming JBI exchanges.
This pattern implements the Message Filter pattern.
Wiki Markup |
---|
{snippet:id=message-filter|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
Pipeline
The Pipeline component is a bridge between an In-Only (or Robust-In-Only) MEP and an In-Out MEP. When the Pipeline receives an In-Only MEP, it will send the input in an In-Out MEP to the tranformer destination and forward the response in an In-Only MEP to the target destination.
The old org.apache.servicemix.components.util.PipelineComponent will be deprecated. This one offers the same feature but can be safely clustered and use in a transactional enviromnent.
Wiki Markup |
---|
{snippet:id=pipeline|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
Static Recipient List
The StaticRecipientList component will forward an input In-Only or Robust-In-Only exchange to a list of known recipients.
This component implements the Recipient List pattern, with the limitation that the recipient list is static.
Wiki Markup |
---|
{snippet:id=static-recipient-list|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
Static Routing Slip
A RoutingSlip component can be used to route an incoming In-Out exchange through a series of target services.
This component implements the Routing Slip pattern, with the limitation that the routing table is static.
This component only uses In-Out MEPs and errors or faults sent by targets are reported back to the consumer, thus interrupting the routing process.
Wiki Markup |
---|
{snippet:id=static-routing-slip|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
Wire Tap
A WireTap component can be used to forward a copy of the input message to a listener.
This component implements the WireTap pattern.
It can handle all 4 standard MEPs, but will only send an In-Only MEP to the listener.
Wiki Markup |
---|
{snippet:id=wire-tap|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
XPath Splitter
The XPathSplitter component implements the Splitter pattern using an xpath expression to split the incoming xml.
Wiki Markup |
---|
{snippet:id=xpath-splitter|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
SplitAggregator
The SplitAggregator is an aggregator mainly usefull to collect messages that have been created using a splitter.
It relies on several properties that should be set on the exchanges (count, index, correlationId).
Wiki Markup |
---|
{snippet:id=split-aggregator|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
Tips
ExchangeTarget
All patterns use the <exchange-target /> tag to specify the target of a JBI exchange.
This element has the following attributes:
Name | Type | Description |
---|---|---|
interface | QName | the QName of the target interface. One of service or interface attribute is required |
operation | QName | the QName of the target operation (optional) |
service | QName | the QName of the target service. One of service or interface attribute is required |
endpoint | String | the name of the target JBI endpoint, only used when service is set |
uri | String | uri used to target the exchange (see URIs) |
If you want to target a given interface, just set the interface attribute. Else you have to set the service attribute, and optionally the endpoint attribute if you want to specify the JBI endpoint instead of a service name.
NamespaceContext
Some patterns use XPath expression. To use such expressions on an xml with namespaces, you need to define a NamespaceContext.
Wiki Markup |
---|
{snippet:id=namespace-context|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/servicemix-eip/src/test/resources/org/apache/servicemix/eip/spring.xml} |
This NamespaceContext can be referenced by a namespaceContext attribute as shown in the XPathSplitter or MessageFilter examples.
Predicates
Some patterns uses predicates to test a given JBI exchange. The only predicate currently implemented is the XPathPredicate, but you can implement your own and deploy it with the service unit.
TODO: link to a page documenting the classpath / location elements for deploying code inside xbean SU
Creating your own patterns
Some classes have been designed to be extensible, this includes:
- org.apache.servicemix.eip.support.AbstractAggregator
- org.apache.servicemix.eip.support.AbstractSplitter