product-ei
product-ei copied to clipboard
Issue with Header Mediator in multi thread environment
Description: Header Mediator is not working as expected in multi threaded environments.
I built a flow which will be invoked concurrently my many users. I am setting a property called 'clientId'( unique identifier for each user) in header mediator and also in the message context(say a payload factory). In some rare scenario, I have observed that the clientId in header and payload factory are showing differently. After debugging further, I noticed that clientId in header mediator is coming from a different thread ( thread2) and clientId in payload factory is set from current thread( thread1). Say the current thread is thread1.
After extracting logs from thread2, clientId in header and payload factory in thread2 are set correctly (with value of thread2)
sample code where the issue is observed
<payloadFactory description="gl-detail payload" media-type="json">
<format>{ "clientId": $1, "sourceName": "$2","sourceId": "$3" }
</format>
<args>
<arg evaluator="xml" expression="get-property('clientId')"/>
<arg evaluator="xml" expression="get-property('sourceName')"/>
<arg evaluator="xml" expression="get-property('sourceId')"/>
</args>
</payloadFactory>
<header description="clientid" expression="get-property('clientId')" name="clientid" scope="transport"/>
<call blocking="true">
<endpoint key="gov:endpoints/UpdateSourceDetailEP.xml"/>
</call>
Version : WSO2 Micro Integrator 1.2
This use case is causing issues for us as the critical client level information is getting swapped in our production environment. I am referring to this link which says that header mediator is conditionally content aware and guessing this could be an issue. https://ei.docs.wso2.com/en/latest/micro-integrator/references/mediators/header-Mediator/
I couldn't find much help online trying to understand this issue. Kindly help us to fix this problem at the earliest.
Thanks in advance.