简体   繁体   English

1个队列中的同步和异步消息接收器(带有ActiveMQ的Spring)JMS API

[英]Synchronous & Asynchronous Message Receiver in 1 queue (Spring w/ ActiveMQ) JMS API

I am using Spring JMS with ActiveMQ as the broker and running the application on Tomcat. 我正在将Spring JMS与ActiveMQ用作代理,并在Tomcat上运行该应用程序。 I have one queue, let's say queue.a. 我有一个队列,比方说队列。 In my web app, I already have a MessageListener running whenever I start my web app. 在我的Web应用程序中,每当我启动Web应用程序时,我已经有一个MessageListener运行。 The only thing is, I want to add some kind of queue consumer but synchronously. 唯一的事情是,我想同步添加某种队列使用者。 I already try using JmsTemplate etc. But when both of my consumer (listener async & consumer synchronous) is up and I trigger the .receive() method, the message sent to the queue always sucked up to the message listener that have been always online since the web app started. 我已经尝试使用JmsTemplate等。但是,当我的两个使用者(侦听器异步和使用者同步)都启动并且触发.receive()方法时,发送到队列的消息总是被一直在线的消息侦听器吸收。自网络应用启动以来。 After the end of the timeout,the synchronous receiver did not consume any message at all. 超时结束后,同步接收器完全不消耗任何消息。

But,when I comment out the messageListener, the synchronous customer run well. 但是,当我注释掉messageListener时,同步客户运行良好。

I'm still a newbie,do any of you have any way to make what I want possible? 我仍然是新手,你们中的任何人有什么办法使我想要的成为可能吗? Thanks! 谢谢! Sorry for my bad english :( 对不起,我的英语不好 :(

<bean id="someQueue" class="org.apache.activemq.command.ActiveMQQueue">
  <constructor-arg index="0" value="TEST.QUEUE?consumer.priority=10" />
</bean>

and then, set it to your listener/receiver bean: 然后将其设置为您的侦听器/接收器Bean:

<bean id="someReceiver" class="blah.blah.SomeReceiver">
  <property name="destination" ref="someQueue" />
  <property name="jmsTemplate" ref="jmsTemplate" />
</bean>

Does this solve your problem? 这样可以解决您的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM