Friday, March 2, 2018

How to correlate the incoming messages to outgoing messages in WSO2 ESB/EI



When there are many requests coming to ESB and there are failures in the responses, you will need to correlate the corresponding incoming request of the failed outgoing response in order to find the root cause of the issue.

Even though there is a message ID generated for each request and response, there will be two message ID's generated for both leaving it difficult for a user to correlate the request and response.

One way to correlate the two messages is by getting the MessageID of the incoming request in the in-sequence, save it in a property and log the same property in the out-sequence.

You can refer the following sample to achieve this. Copy the following synapse proxy configuration in WSO2 ESB/EI. Follow this document for more information on creating a proxy service.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="TestProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="https,http">
   <target>
      <inSequence>
         <property expression="get-property('MessageID')" name="msgID"/>
         <log level="full">
            <property expression="get-property('msgID')" name="MessageID IN===:"/>
         </log>
         <send>
            <endpoint>
               <address uri="http://www.mocky.io/v2/5a696f212e000056097a7459"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log level="full">
            <property expression="get-property('msgID')" name="MessageID OUT===:"/>
         </log>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

After invoking the service, you will see the logs as below. Highlighted in yellow is the message ID's to correlate the messages.

[2018-01-25 16:19:32,074]  INFO - LogMediator To: /services/TestProxy.TestProxyHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:dfc7d874-0b6c-4348-beb4-de6bc34c0106, Direction: request, MessageID IN===: = urn:uuid:dfc7d874-0b6c-4348-beb4-de6bc34c0106, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope>
[2018-01-25 16:19:32,228]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3cf4faa1-2298-4373-8cf2-3eddc2dd9e2c, Direction: response, MessageID OUT===: = urn:uuid:dfc7d874-0b6c-4348-beb4-de6bc34c0106, Payload: {"Test":"response"}
Hope you find it useful :)




No comments:

Post a Comment