我有两个单独的消息发布到staging.queue。我希望登台队列的JMS使用者在消费者来自staging.queue的所有消息之前等待10秒。我有以下策略:
<jms:activemq-connector name="Active_MQ" username="admin" password="admin" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ">
<service-overrides transactedMessageReceiver="com.mulesoft.mule.transport.jms.TransactedPollingJmsMessageReceiver" />
</jms:activemq-connector>
<flow name="integration-consumer-client2" doc:name="integration-consumer-client2">
<jms:inbound-endpoint queue="client2.publish" connector-ref="Active_MQ" doc:name="JMS">
</jms:inbound-endpoint>
<logger message="Consumes Client 2 = #[payload]" level="INFO" doc:name="Logger"/>
<logger message="Client 2 Correlation = #[message.correlationId] and Correlation sequence = #[message.correlationSequence]" level="INFO" doc:name="Logger"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<jms:outbound-endpoint queue="waiting.queue" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
<flow name="integration-consumer-client" doc:name="integration-consumer-client">
<jms:inbound-endpoint doc:name="JMS" connector-ref="Active_MQ" queue="client1.publish">
</jms:inbound-endpoint>
<logger message="Consumes Client 1 = #[payload]" level="INFO" doc:name="Logger"/>
<logger message="Client Correlation = #[message.correlationId] and Correlation sequence = #[message.correlationSequence]" level="INFO" doc:name="Logger"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<jms:outbound-endpoint queue="waiting.queue" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
<flow name="integration-Flow3" doc:name="integration-Flow3">
<jms:inbound-endpoint queue="staging.queue" connector-ref="Active_MQ" doc:name="JMS">
<properties>
<spring:entry key="pollingFrequency" value="10000" />
</properties>
</jms:inbound-endpoint>
<logger message="after poller = #[payload]" level="INFO" doc:name="Logger"/>
</flow>
但消费者不会等待10秒钟。它立即消费消息
答案 0 :(得分:1)
您可以通过以下方式完成: -
Mule模块请求者是能够在流程中间调用任何入站端点的组件。
您可以在此处找到骡子模块请求者的详细信息https://github.com/mulesoft/mule-module-requester和http://blogs.mulesoft.org/introducing-the-mule-requester-module/
只需使用它来调用JMS入站端点,q ueue =“staging.queue” ..
因为你将在 Mule模块请求者之前使用GroovyScript .Groovy脚本将负责持有计时器..(你需要在你的Groovy脚本中设置sleep()方法)..那是所有