servicemix-eipPage edited by Jean-Baptiste OnofréChanges (19)
Full Contentservicemix-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:
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. Maven ArchetypeYou can create a EIP Service Unit using the servicemix-eip-service-unit archetype: mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-eip-service-unit \ -DarchetypeVersion=2010.01 \ -DgroupId=your.group.id \ -DartifactId=your.artifact.id \ -Dversion=your-version
XPath SplitterThe XPathSplitter component implements the Splitter pattern using an xpath _expression_ to split the incoming xml. <eip:xpath-splitter service="test:xpathSplitter" endpoint="endpoint" xpath="/*/*" namespaceContext="#nsContext"> <eip:target> <eip:exchange-target uri="service:http://test/router" /> </eip:target> </eip:xpath-splitter> SplitAggregatorThe SplitAggregator is an aggregator mainly usefull to collect messages that have been created using a splitter. <eip:split-aggregator service="test:aggregator" endpoint="endpoint"> <eip:target> <eip:exchange-target service="test:trace5" /> </eip:target> </eip:split-aggregator> Content EnricherWith a Content Enricher you can extract additional information from a source and add this information to your message. This is useful if the calling service for example extracts a 'userID' and your target system is only aware of a 'userName'. By using the Content-Enricher you could extract this information from a source system and add this additional information ('userName') to your message. <eip:content-enricher service="test:contentEnricher" endpoint="endpoint"> <eip:enricherTarget> <eip:exchange-target service="test:additionalInformationExtracter" /> </eip:enricherTarget> <eip:target> <eip:exchange-target service="test:myTarget" /> </eip:target> </eip:content-enricher> ResequencerA resequencer re-orders incoming In-Only or Robust-In-Only exchanges and sends them synchronously to a targets service. Synchronous sending ensures that messages arrive in correct order at the target service. This component implements the Resequencer pattern. It works on (continuous) streams of message exchanges using a timeout policy. Since the resequencer doesn't make batch reads there's no need to know the number of messages to be re-ordered in advance (although a capacity parameter prevents the resequencer from running out of memory). If the maximum out-of-sequence time difference between messages in a message stream is known, the resequencer's timeout parameter should be set to this value (milliseconds). In this case it is guaranteed that all elements of a stream are delivered in correct order to the target service. The lower the timeout value is compared to the out-of-sequence time difference the higher is the probability for out-of-sequence messages sent by this resequencer. Large timeout values should be supported by sufficiently high capacity values. For comparing elements of a sequence the resequencer component can be configured with a sequence element comparator. A default comparator is provided that compares message exchanges based on Long sequence numbers. This comparator expects the sequence number to be the value of the org.apache.servicemix.eip.sequence.number property of the exchanges's in-NormalizedMessage. The name of the property can be customized in the comparator configuration (see below). You may also provide a custom comparator by implementing the SequenceElementComparator interface. <eip:resequencer service="sample:Resequencer" endpoint="ResequencerEndpoint" comparator="#comparator" capacity="100" timeout="2000"> <eip:target> <eip:exchange-target service="sample:SampleTarget" /> </eip:target> </eip:resequencer> <!-- Configure default comparator with custom sequence number property --> <eip:default-comparator id="comparator" sequenceNumberKey="seqnum"/> A running example can be downloaded from here. In this example, a custom-coded message sender sends messages in "wrong" order to the resequencer. The resequencer re-orders these messages and (synchronously) sends them to a file sender-endpoint. The file sender-enpoint writes the messages (in proper order) to the work/output directory. AsyncBridgeThe AsyncBridge is the opposite of the Pipeline: it bridges an InOut exchange with two InOnly exchanges. <eip:async-bridge service="sample:AsyncBridge" endpoint="AsyncBridgeEndpoint" <eip:target> <eip:exchange-target service="sample:SampleTarget" /> </eip:target> </eip:async-bridge> Correlation IdThere is a convention between the AsyncBridge and the target on how the correlation id is transmitted. The correlation id can only be transmitted from the AnsycBridge to the target using a message property . The property name can be customized. On the other hand, the correlation id coming back from the target could be set in a message property or the message payload. The AsyncBridge could use an _expression_ to extract the correlation id from the message returning from the target. <eip:async-bridge service="sample:AsyncBridge" endpoint="AsyncBridgeEndpoint" responseCorrIdProperty="correlationIdProperty" responseCorrId="#responseCorrIdExpression"> <eip:target> <eip:exchange-target service="sample:SampleTarget" /> </eip:target> </eip:async-bridge> <bean id="responseCorrIdExpression" class="org.apache.servicemix._expression_.JAXPStringXPathExpression" > <contructor-arg value="/my-response/message/@corrId"/> </bean> As you can see from the sample above the responseCorrIdProperty is used to set the name of the property that the target will query to get the correlation id sent by the AsyncBridge. In other words, the target will do something like this to extract the correlation id: String correlationId = exchange.getProperty("correlationIdProperty"); The responseCorrId is set with an instance of type org.apache.servicemix._expression_._expression_, in this case the class org.apache.servicemix._expression_.JAXPStringXPathExpression. TipsExchangeTargetAll patterns use the <exchange-target /> tag to specify the target of a JBI exchange.
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. NamespaceContextSome patterns use XPath _expression_. To use such expressions on an xml with namespaces, you need to define a NamespaceContext. <eip:namespace-context id="nsContext"> <eip:namespaces> <eip:namespace prefix="test">http://test</eip:namespace> </eip:namespaces> </eip:namespace-context> This NamespaceContext can be referenced by a namespaceContext attribute as shown in the XPathSplitter or MessageFilter examples. PredicatesSome 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 Configuring temporary message storageMany of the pattern implementation need to store MessageExchanges temporarily. An example: the aggregator will need to keep track of the MessageExchange it is aggregating. By default, the EIPs use a plain MemoryStoreFactory to create in-memory stores, but there are other options. If you set the timeout property on the MemoryStoreFactory, it will evict old object from the in-memory store to avoid a memory leak. You can also use a JDBCStoreFactory to store data in a database instead of in memory. Example: to use an in-memory store with timeout for a storing active and closed aggregations in a <split-aggregator/>, you can do <eip:split-aggregator service="test:aggregator" endpoint="endpoint" storeFactory="#StoreFactory" closedAggregateStoreFactory="#StoreFactory"> <eip:target> <eip:exchange-target service="test:trace5" /> </eip:target> </eip:split-aggregator> <bean id="StoreFactory" class="org.apache.servicemix.store.MemoryStoreFactory"> <property name="timeout" value="120000"/> <!-- 2 minute timeout --> </bean> Creating your own patternsSome classes have been designed to be extensible, this includes:
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache ServiceMix > servicemix-eip confluence
- [CONF] Apache ServiceMix > servicemix-eip confluence
- [CONF] Apache ServiceMix > servicemix-eip confluence
