1

I need to get a unique ID to trace messages through logs. I am using WSO2 ESB 4.8.1. I have found an article related to WSO2 ESB 5.0.0. http://nuwanzone.blogspot.it/2016/12/wso2-esb-tracing-messages-through-logs.html . It describes how setting a unique ID per each message using the MessageContext object so that I can access it from anywhere within the message flow. Is it possible implement a similar solution in WSO2 ESB 4.8.1 too? (porting that) solution in WSO2 ESB 4.8.1? Do you know different solutions?

Community
  • 1
  • 1
  • If you´re dealing with SOAP messages then you can use the MessageID property. This property is avaiable using the regular get-property() XPath function in a mediator. – Philippe Sevestre Apr 12 '17 at 15:09
  • Yes you cann use same with older version. – Thusitha Thilina Dayaratne Apr 13 '17 at 01:27
  • Thank you @PhilippeSevestre for your answer. Yes, I deal SOAP messages. I will try as soon as possible Thanks in advance. – Stefano Lizzio Apr 13 '17 at 09:12
  • Thank you @ThusithaThilinaDayaratne for your answer. I have tried to use MDC solution described in article, using one of mine proxy services but without success. Log4j doesn't write unique id in my log. WSO2 ESB 4.8.1 use jdk 1.7 while jar to add in wso2esb-4.8.1\repository\components\lib has been compiled using jdk 1.8. Could be this the problem? Thanks in advance. – Stefano Lizzio Apr 13 '17 at 09:16

1 Answers1

1

You can save the MessageID in a property at startup, and add it to your log mediators. Example:

<property description="SetMessageUUID" expression="fn:substring-after(get-property('MessageID'), 'urn:uuid:')" name="MessageUUID" scope="default" type ="STRING"/>
<log>
    <property name="Step" expression="Request service A"/>
    <property name="ID" expression="get-property('MessageUUID')"/>
</log>
<call>
.....
</call>
<log>
    <property name="Step" expression="Response service A"/>
    <property name="ID" expression="get-property('MessageUUID')"/>
</log>
Alemão
  • 33
  • 8