Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
<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.

Code Block

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

Code Block

 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.

Tips

ExchangeTarget

All patterns use the <exchange-target /> tag to specify the target of a JBI exchange.
This element has the following attributes:

...