Mule异步请求 - 回复

时间:2014-02-24 14:32:41

标签: mule esb mule-studio

我实际上通过端口8081上的http请求通过exe调用expression-componentexe在端口8082上发送http请求,我能够记录输出。 最后,我必须将回复流的输出发送回主流,但我不知道如何......

这是我的代码:

<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>

1 个答案:

答案 0 :(得分:1)

您必须确保通过MULE_CORRELATION_IDexe传递http://localhost:8082消息属性,否则request-reply消息处理器无法关联异步回复根据当前的要求。

例如,将相关ID传递给exe的第二个参数:

<expression-component doc:name="Expression">
  Runtime.getRuntime().exec("C:\\myfile.exe arg1 " + message.correlationId);
</expression-component>

并确保exe在名为http://localhost:8082的HTTP标头中将关联ID传播到X-MULE_CORRELATION_ID