I actually invoke an exe
with the expression-component
through a http-request on port 8081. The exe
sends a http-request on port 8082 and I'm able to log the output.
Finally i have to send the output of the reply-flow back to the main-flow but i dont know how...
Here is my code:
<flow name="mainFlow" doc:name="mainFlow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8081" doc:name="HTTP" />
<request-reply timeout="10000">
<vm:outbound-endpoint path="request" exchange-pattern="one-way"/>
<vm:inbound-endpoint path="reply" exchange-pattern="one-way"/>
</request-reply>
</flow>
<flow name="request" doc:name="request">
<vm:inbound-endpoint path="request" doc:name="VM" />
<expression-component doc:name="Expression">Runtime.getRuntime().exec("C:\\myfile.exe arg1");</expression-component>
</flow>
<flow name="reply" doc:name="reply">
<http:inbound-endpoint address="http://localhost:8082" doc:name="HTTP" exchange-pattern="one-way" />
<logger message="#[message.inboundProperties['test']]" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint path="reply" doc:name="VM" exchange-pattern="one-way"/>
</flow>
You have to make sure you are carrying the MULE_CORRELATION_ID
message property through the exe
down to http://localhost:8082
otherwise the request-reply
message processor has no way to correlate the asynchronous reply with the current request.
For example, pass the correlation ID has a second argument to the exe
:
<expression-component doc:name="Expression">
Runtime.getRuntime().exec("C:\\myfile.exe arg1 " + message.correlationId);
</expression-component>
And make sure the exe
propagates the correlation ID towards http://localhost:8082
in an HTTP header named X-MULE_CORRELATION_ID
.