Implementing WireTap EIP in WSO2 ESB Proxy Service

16 Apr

One of the EIP patterns is the WireTap. In this pattern you can extract a copy of the message from the flow without interfering the process.

Wire Tap

Wire Tap


The way to do this in the WSO2 ESB is by simply using the Clone mediator in the proxy service. Here is an example how I used it in my flow:

<clone continueParent="true" id="wireTap">
  <target>
    <sequence>
      <property action="set" name="target.endpoint" scope="default" type="STRING" value="MyLoggingServiceEndPoint"/>
      <property action="set" name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
      <property action="set" name="OUT_ONLY" scope="default" type="STRING" value="true"/>
      <store messageStore="MyLoggingQueue"/>
    </sequence>
  </target>
</clone>

As you can see it is quite straightforward as it is with most of the mediators in WSO2. The important properties here are the attribute ‘continueParent’ of the ‘clone’ element. With this attribute we tell the ESB to continue the ‘normal’ flow of the message and start a new flow for the cloned message. If we set this one to false the ‘normal’ flow will be dropped and only the cloned one will continue.
The other ‘specific’ thing in my configuration are the properties I add to the message. The ‘target.endpoint’ property is added to tell the ESB where the cloned message should be sent to. The other two properties take care of the handling of the cloned mesage. I put the cloned message in a Message Store (ActiveMQ queue) and have a Message Forwarding Processor pick it up from there to put it in a database (by using a WSO2 Data Service). These are all one-way actions so I put these properties on the message to indicate to the ESB that it shouldn’t expect a response. If I don’t put these properties here the Message Processor will take the message from the queue and put it in the database but since it doesn’t receive a response it will not remove the message from the queue but try agian. And again. And again….

Follow

Get every new post delivered to your Inbox.

Join 99 other followers

%d bloggers like this: