JBI Support deprecated in Apache ServiceMix 4

JBI 1.0 support is available in Apache ServiceMix 4 to allow existing users to migrate more easily to this latest version - if you're a new user, you should consider JBI deprecated and not use it for your project. Take a look at our technology selection guidelines for more information.

servicemix-eip

Overview

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.

Namespace and xbean.xml

The namespace URI for the servicemix-bean JBI component is http://servicemix.apache.org/eip/1.0. This is an example of an xbean.xml file with a namespace definition with prefix eip.

<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:eip="http://servicemix.apache.org/eip/1.0"
      xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
  <!-- Pipeline example -->
  <eip:pipeline service="test:pipeline" endpoint="endpoint">
  <eip:transformer>
    <eip:exchange-target service="test:transformer" />
  </eip:transformer>
  <eip:target>
    <eip:exchange-target service="test:trace" />
  </eip:target>
</eip:pipeline>
</beans>

Endpoint types

The servicemix-eip component defines several endpoint types:

  • eip:content-based-router :: Implements the Content-Based Router EIP

  • eip:message-filter :: Implements the Message Filter EIP

  • eip:pipeline :: Implements the Pipeline EIP

  • eip:static-recipient-list :: Implements the Static Recipient List EIP

  • eip:static-routing-slip :: Implements the Static Routing Slip EIP

  • eip:wire-tap :: Implements the Wire Tap EIP

  • eip:xpath-splitter :: Uses XPath to split a message

  • eip:split-aggregator :: Aggregates messages that have been split by the xpath-splitter

  • eip:content-enricher :: Implements the Content Enricher EIP

  • eip:resequencer :: Implements the Resequencer EIP

  • eip:async-bridge :: Handles an InOut exchange by correlating to separate InOnly exchanges



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.

Content Based Router

ContentBasedRouter can be used for all kind of content-based routing.
This pattern implements the Content-Based Router pattern.




Endpoint properties

Property Name Type Description
endpoint java.lang.String The name of the endpoint.
forwardOperation boolean Forward the operation qname when sending the exchange to the target.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
rules (org.apache.servicemix.eip.support.RoutingRule)\* The list of routing rules.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

Message Filter

MessageFilter allows filtering incoming JBI exchanges. As it drops unwanted messages and in an InOut exchange a response is required, MessageFilter and InOut MEPs cannot be used together.
This pattern implements the Message Filter pattern.




Endpoint properties

Property Name Type Description
endpoint java.lang.String The name of the endpoint.
filter org.apache.servicemix.eip.support.Predicate The filter to use on incoming messages
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
reportErrors boolean Indicates if faults and errors from recipients should be sent back to the consumer. In such a case, only the first fault or error received will be reported. Note that if the consumer is synchronous, it will be blocked until all recipients successfully acked the exchange, or a fault or error is reported, and the exchange will be kept in the store for recovery.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
target org.apache.servicemix.eip.support.ExchangeTarget The main target destination which will receive the exchange
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

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.




In the default configuration, faults sent by the transformer component are sent back to the consumer as faults if the exchange MEP supports them, or as errors (for InOnly exchanges). This behavior can be changed by setting the sendFaultsToTarget attribute to true, in which case faults will be sent to the target component, or by adding a faultsTarget element where faults should be sent.

Endpoint properties

Property Name Type Description
copyAttachments boolean Should message attachments be copied ?
copyProperties boolean Should message properties be copied ?
endpoint java.lang.String The name of the endpoint.
faultsTarget org.apache.servicemix.eip.support.ExchangeTarget The address of the endpoint to send faults to
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
sendFaultsToTarget boolean When the faultsTarget is not specified, faults may be sent to the target endpoint if this flag is set to <code>true</code>
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
target org.apache.servicemix.eip.support.ExchangeTarget The address of the target endpoint
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
transformer org.apache.servicemix.eip.support.ExchangeTarget The adress of the in-out endpoint acting as a transformer
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

Static Recipeint 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.




Endpoint properties

Property Name Type Description
endpoint java.lang.String The name of the endpoint.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
recipients (org.apache.servicemix.eip.support.ExchangeTarget)\* A list of recipients that will each receive a copy of the input message.
reportErrors boolean Indicates if faults and errors from recipients should be sent back to the consumer. In such a case, only the first fault or error received will be reported. Note that if the consumer is synchronous, it will be blocked until all recipients successfully acked the exchange, or a fault or error is reported, and the exchange will be kept in the store for recovery.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

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.




Endpoint properties

Property Name Type Description
endpoint java.lang.String The name of the endpoint.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
targets (org.apache.servicemix.eip.support.ExchangeTarget)\* List of target endpoints used in the RoutingSlip
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

Wire Tap

A WireTap component can be used to forward a copy of the input message to a listener in a proxy fashion.
This component implements the WireTap pattern.
It can handle all four standard MEPs, but will only send an In-Only MEP to the listener.
The originating service must be configured to send messages to the WireTap directly.
In the case of an In-Out MEP, this means that the WireTap needs to be configured to send the exchange along to the destination service.






Similar to the example above, the WireTap can also be used:

  • to forward the output message of an exchange using <eip:outListener/>

  • to forward the fault message of an exchange using <eip:faultListener/>

Endpoint properties

Property Name Type Description
copyProperties boolean If copyProperties is <code>true</code>, properties on the in message will be copied to the out / fault message before it is sent.
endpoint java.lang.String The name of the endpoint.
faultListener org.apache.servicemix.eip.support.ExchangeTarget The listener destination for fault messages
inListener org.apache.servicemix.eip.support.ExchangeTarget The listener destination for in messages
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
outListener org.apache.servicemix.eip.support.ExchangeTarget The listener destination for out messages
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
target org.apache.servicemix.eip.support.ExchangeTarget The main target destination which will receive the exchange
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

XPath Splitter

The XPathSplitter component implements the Splitter pattern using an xpath expression to split the incoming xml.




Endpoint properties

Property Name Type Description
endpoint java.lang.String The name of the endpoint.
factory javax.xml.xpath.XPathFactory The XPath factory. If no factory is explicitely configured, a defaut one will be created using <code>XPathFactory.newInstance()</code>.
forwardAttachments boolean Indicates if incoming attachments should be forwarded with the new exchanges.
forwardProperties boolean Indicates if properties on the incoming message should be forwarded.
functionResolver javax.xml.xpath.XPathFunctionResolver The function resolver.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
namespaceContext javax.xml.namespace.NamespaceContext The namespace context to use when evaluating the xpath expression
reportErrors boolean Indicates if faults and errors from splitted parts should be sent back to the consumer. In such a case, only the first fault or error received will be reported. Note that if the consumer is synchronous, it will be blocked until all parts have been successfully acked, or a fault or error is reported, and the exchange will be kept in the store for recovery.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
synchronous boolean Specifies wether exchanges for all parts are sent synchronously or not.
target org.apache.servicemix.eip.support.ExchangeTarget The address of the target endpoint.
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
variableResolver org.apache.servicemix.expression.MessageVariableResolver The variable resolver. The default one will enable the use of properties on the message, exchange, as well as making system properties and environment properties available.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.
xpath java.lang.String The xpath expression used to split the input message.

Split Aggregator

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).



Endpoint properties

Content Enricher

With 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>

Endpoint properties

Property Name Type Description
copyAttachments boolean If this is set to <code>true</code>, message attachments from the incoming exchange and the enricher exchange will be copied to the outgoing message exchange. The default value is <code>false</code> (do not copy message atachments).
copyProperties boolean If this is set to <code>true</code>, message properties from the incoming exchange and the enricher exchange will be copied to the outgoing message exchange. The default value is <code>false</code> (do not copy message properties).
endpoint java.lang.String The name of the endpoint.
enricherElementName javax.xml.namespace.QName returns the QName of the resulting root node
enricherTarget org.apache.servicemix.eip.support.ExchangeTarget The target that will receive a copy of the input message and return an addtitional content.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
requestElementName javax.xml.namespace.QName Returns the QName of the element which contains the 'IN Message' within the response message
resultElementName javax.xml.namespace.QName Returns the QName of the element which contains the message which was produced by the enricherTarget within the response message
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
target org.apache.servicemix.eip.support.ExchangeTarget The target where the enriched exchanges are sent.
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

Eip Resequencer

A 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.

Endpoint properties

Property Name Type Description
capacity int The capacity of this resequencer. The capacity determines the maximum number of message that will be kept in memory to put the messages back in sequence. This determine how far two messages can be in the list of messages while still being put back in sequence.
comparator org.apache.servicemix.eip.support.resequence.SequenceElementComparator The comparator used to determine the sequence order of elements.
endpoint java.lang.String The name of the endpoint.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
target org.apache.servicemix.eip.support.ExchangeTarget
timeout long Set the timeout of this resequencer. This specifies the maximum number of milliseconds that can elapse between two out-of-sync messages.
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

Async Bridge

The AsyncBridge expects an InOut mep as input. It then uses the exchange id of the InOut mep as the correlation id and creates an InOnly message by copying the input message and sends it to the target (with the correlation id set as a property). Next it expects an InOnly to come back with the same correlation id property. When this happens, the message is copied to the out message of the original exchange and sent back. If no response is received during the configured amount of time (timeout property in milliseconds), an error will be sent back to the original consumer.

 <eip:async-bridge
  service="sample:AsyncBridge"
  endpoint="AsyncBridgeEndpoint"
  <eip:target>
    <eip:exchange-target service="sample:SampleTarget" />
  </eip:target>
</eip:async-bridge>

Correlation Id

There 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.
This expression resolves the location of the correlation id coming back from the target. In the above example the expression shows that the correlation id comes as part of the message payload in an attribute called "corrId" of the /my-response/message element. In a similar manner the class org.apache.servicemix.expression.PropertyExpression could have been used to locate the correlation id in a message property.

Endpoint properties

Property Name Type Description
endpoint java.lang.String The name of the endpoint.
interfaceName javax.xml.namespace.QName The qualified name of the interface exposed by the endpoint.
lockManager org.apache.servicemix.common.locks.LockManager The lock manager to use for this endpoint. If none is explicitely specified a default implementation will be provided.
requestCorrId org.apache.servicemix.expression.Expression The expression used to compute the correlation id used to correlate the response and the request. The default behavior is to use the exchange id of the incoming In-Out exchange as the correlation id.
responseCorrId org.apache.servicemix.expression.Expression The expression used to compute the correlation id from the response exchange. The value computed by this expression must match the one from the {@link #setRequestCorrId} expression. The default value is null, but if no specific expression is configured, an expression will be created which will extract the response correlation id from the {@link #setResponseCorrIdProperty(String)} property on the exchange.
responseCorrIdProperty java.lang.String Name of the property used by default to compute the correlation id on the response exchange.
service javax.xml.namespace.QName The qualified name of the service the endpoint exposes.
store org.apache.servicemix.store.Store Configure the store to use. If none is explicitely configured, the storeFactory will be used to create one.
storeFactory org.apache.servicemix.store.StoreFactory The store factory to use when creating a store. If no factory is explicitely defined, an in-memory only factory will be created.
target org.apache.servicemix.eip.support.ExchangeTarget The target which will be used to send an In-Only or Robust-In-Only exchange to. When receiving an In-Out exchange, the async bridge will create an In-Only request and send it to the specified target. It then expects another In-Only exchange to come back as the response, which will be set as the Out message on the In-Out exchange. This property is mandatory and must be set to a valid target.
timeout long The timeout property controls the amount of time that the async bridge will wait for the response after having sent the request. The default value is 0 which means that no timeout apply. If set to a non zero value, a timer will be started when after the request is sent. When the timer expires, the In-Out exchange will be sent back with an error status and a {@link java.util.concurrent.TimeoutException} as the cause of the error. The value represents the number of milliseconds to wait.
timerManager org.apache.servicemix.timers.TimerManager The timer manager to use for this endpoint. If none is explicitely configured, a default implementation will be provided.
useRobustInOnly boolean Boolean flag to control if In-Only or Robust-In-Only exchange should be used when sending the request. The default value is <code>false</code> which means that an In-Only exchange will be used. When using a Robust-In-Only exchange and when a fault is received, this fault will be sent back to the consumer on the In-Out exchange and the response exchange (if any) would be discarded. For both In-Only and Robust-In-Only, if the request exchange comes back with an Error status, this error will be conveyed back to the consumer in the same way.
wsdlExchangeTarget org.apache.servicemix.eip.support.ExchangeTarget An exchange target pointing to a JBI endpoint that will be used to load the WSDL describing this endpoint. This can be used when the endpoint proxies another endpoint so that the same WSDL definition will be exposed."
wsdlResource org.springframework.core.io.Resource When specified, this spring resource will be used to load the WSDL that will be exposed as a description for this endpoint. This property can be used to explicitely define the WSDL to be exposed by this endpoint. This property takes precedence over the wsdlExchangeTarget property.

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)

NamespaceContext

Some patterns use XPath expression. To use such expressions on an xml with namespaces, you need to define a NamespaceContext.


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.

Configuring temporary message storage

Many 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 patterns

Some classes have been designed to be extensible, this includes:

  • org.apache.servicemix.eip.support.AbstractAggregator

  • org.apache.servicemix.eip.support.AbstractSplitter