ule子:JMS答复队列消耗了所有消息.我要处理即将回复队列的消息 [英] Mule: JMS reply queue consumes all the messages. I want to process messages that coming to reply queue

查看:159
本文介绍了ule子:JMS答复队列消耗了所有消息.我要处理即将回复队列的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有JMS request-reply块的Mule(3.5)流.我看到所有要回复队列的消息都自动消耗掉了.我想处理来到jms回复队列的消息.到目前为止,我已经尝试过使用jms:selector和jms requester模块,但是没有运气.有什么办法可以做到这一点?

I've a Mule(3.5) flow with JMS request-reply block. I saw that all the messages coming to reply queue get consumed automatically. I would like to process messages that come to jms reply queue. I've tried with jms:selector and jms requester module so far but no luck. Is there any way to achieve this?

代码:

<mule>
<flow name="main" doc:name="main">

        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" path="test" port="2000" doc:name="HTTP"/>

        <logger message="starting main flow" level="INFO" doc:name="Logger"/>

        <request-reply storePrefix="mainFlow">  
            <jms:outbound-endpoint queue="StudioIN" connector-ref="Active_MQ1"  exchange-pattern="one-way"/>
            <jms:inbound-endpoint queue="StudioOUT" connector-ref="Active_MQ1" exchange-pattern="one-way">
                <property key="selector" value="JMSCorrelationID='#[message.correlationId]'"/>
            </jms:inbound-endpoint> 
        </request-reply>
    </flow>

    <flow name="worker" doc:name="worker">
                <jms:inbound-endpoint queue="StudioIN" connector-ref="Active_MQ1" doc:name="JMS"/>
            <async doc:name="Async">
                <logger message="starting worker task(s) .... Payload: #[payload], Request: #[message.inboundProperties['http.request']]" level="INFO" doc:name="Logger"/>

                <scripting:component doc:name="thread-sleep(10s)">
                    <scripting:script engine="Groovy">
                        System.out.println "about to sleep @ time" + System.currentTimeMillis()
                        Thread.sleep(10000);
                        System.out.println "done sleeping @ time" + System.currentTimeMillis()
                    </scripting:script>
                </scripting:component>
                <logger message="finishing up worker task(s) ...." level="INFO" doc:name="Logger"/>
            </async>
    </flow> 

</mule>

我想处理任何回复队列StudioOUT的操作.有什么适当的方法可以实现这一目标吗?

I would like to process whatever comes to reply queue StudioOUT. Is there any proper way to achieve this?

推荐答案

首先在入站JMS端点

然后尝试以下操作以在 Inbound JMS端点中基于过滤器使用消息:-

Then Try the following to consume message based on filter in Inbound JMS endpoint :-

<jms:inbound-endpoint queue="StudioOUT" connector-ref="Active_MQ1" exchange-pattern="one-way">
 <jms:selector expression="JMSCorrelationID= #[message.correlationId]" /> 

</jms:inbound-endpoint> 

,如果要设置消息的属性并发送到 Outbound JMS端点中的Outbound JMSQueue,请尝试以下操作:

and to if you want to set a property to message and send to a Outbound JMSQueue in Outbound JMS endpoint try the following:

  <jms:outbound-endpoint queue="StudioOUT" connector-ref="Active_MQ" doc:name="JMS">
         <jms:object-to-jmsmessage-transformer name="ObjectToJmsMessage" />

            <message-properties-transformer>
            <add-message-property key="CorrelationID" value="#[message.correlationId]"/> 
            </message-properties-transformer>
   </jms:outbound-endpoint>

更新的流程:- 要为特定类型选择JMS消息,我们需要首先在队列中设置它... 例如,假设我们只需要选择和使用优先级为7 ..的JMS消息.现在,我们将优先级为7的消息发送到JMS队列.

UPDATED FLOW:- To select a JMS message for a particular type we need to set it in the queue first ... For example let's assume we need to select and consume only those JMS message that has priority 7 .. Now lets's send messages to JMS queue with priority as 7 ..

因此,请在您的JMS出站端点中设置以下内容

So set the following in your JMS outbound endpoint

<jms:outbound-endpoint queue="StudioOUT" connector-ref="Active_MQ" doc:name="JMS">
   <jms:object-to-jmsmessage-transformer name="ObjectToJmsMessage" />
         <message-properties-transformer>
           <add-message-property key="Priority" value="7"/> 
    </message-properties-transformer>
</jms:outbound-endpoint>

现在,这会将消息发送到JMS优先级为7的队列.

Now this will send messages to Queue with JMS priority as 7 ..

现在您可以从JMS延迟为7的队列中使用这些消息. 因此,现在在您的JMS入站端点中使用以下内容来过滤消息:-

Now you can consume these messages from queue whose JMS proirity is 7 .. remaing message will be ignored and will not be consumed .. So, Now use the following in your JMS inbound endpoint to filter the messages :-

<jms:inbound-endpoint queue="StudioOUT" connector-ref="Active_MQ1" exchange-pattern="one-way">
<jms:selector expression="JMSPriority = 7" /> 
</jms:inbound-endpoint> 

这里将只使用优先级为7的消息..现在,您可以配置入站以从队列中选择特定类型的消息..但请确保该特定类型的消息(此处优先级为7的消息) )存在于JMS队列中...为此,您需要使用我现在向您展示的JMS出站端点向JMS队列发送少量消息.

Here only messages will be consumed which has priority as 7 .. Now you can configure your inbound to select a particular type of messages from queue .. but make sure that, messages of that particular type (here messages with priority=7) exists in JMS queue .. So .. for that purpose you need to send few messages to JMS queue using JMS Outbound endpoint which I showed you now ..

这篇关于ule子:JMS答复队列消耗了所有消息.我要处理即将回复队列的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆