如何启动a子流以使用HTTP端点从JMS队列中读取消息 [英] How to kick off a mule flow to read messages from a JMS queue using an HTTP endpoint
本文介绍了如何启动a子流以使用HTTP端点从JMS队列中读取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我基本上有两个流程:
- HTTP入站终结点接收批处理XML,将其拆分为多个片段并将其分段到JMS队列中.
- 从JMS队列读取暂存的XML并处理消息.
我需要使用Rest调用来控制上述流程2的执行(即,流程2仅在收到HTTP入站调用时才运行).我正在使用Mule版本3.2.2
I need to control the execution of flow 2 above using a Rest call (i.e) flow 2 should run only when an HTTP inbound call is received. I am using Mule version 3.2.2
以下是流程:
<flow name="flow-stage-input">
<http:inbound-endpoint host="localhost"
port= "8082"
path= "test/order"
exchange-pattern= "request-response"
>
</http:inbound-endpoint>
<object-to-string-transformer></object-to-string-transformer>
<splitter evaluator="xpath" expression="//Test/TestNode" enableCorrelation="ALWAYS"/>
<custom-transformer class="org.testing.transformers.DocumentToString"></custom-transformer>
<pooled-component>
<spring-object bean="receiver"></spring-object>
</pooled-component>
<!-- DECIDE SUCCESS OR FAILURE -->
<choice>
<when expression="//Test/TestNode" evaluator="xpath">
<jms:outbound-endpoint queue="stagingQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
</when>
<otherwise>
<logger message="Skipped staging message due to errors" level="ERROR" />
</otherwise>
</choice>
<collection-aggregator></collection-aggregator>
<custom-transformer class="org.testing.transformers.ListOfStringsToString"></custom-transformer>
<!-- RESPONSE SENT BACK TO CALLER -->
</flow>
<flow name="flow-process-jms-input" >
<jms:inbound-endpoint queue="stagingQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
<pooled-component>
<spring-object bean="processor"></spring-object>
</pooled-component>
<!-- DECIDE SUCCESS OR FAILURE -->
<choice>
<when expression="//ErrorCondition/Path" evaluator="xpath">
<jms:outbound-endpoint queue="errorQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
</when>
<otherwise>
<logger message="Message processed successfully" level="ERROR" />
</otherwise>
</choice>
</flow>
推荐答案
在流2中使用Groovy脚本,使用以下命令从队列中请求一条JMS消息:
Use a Groovy script in flow 2 to request one JMS message from the queue using:
muleContext.client.request("jms://stagingQueue", 0)
如果队列为空,则返回null
,否则返回包含JMS消息的Mule消息.
This will return null
if the queue was empty otherwise a Mule message containing the JMS message.
这篇关于如何启动a子流以使用HTTP端点从JMS队列中读取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文