简体   繁体   English

jms 2共享订户

[英]jms 2 shared subscriber

I have been seeing some issues in our application where two instances of the application were receiving the same message even though their consumers were created using createSharedConsumer and had the same subscription name. 我一直在我们的应用程序中看到一些问题,即使应用程序的两个实例使用createSharedConsumer创建并具有相同的订阅名称,它们的使用者也收到相同的消息。

At first I thought this might be our app or the way we were using SpringJMS so I created a sample application that creates 3 connection factories. 起初,我以为这可能是我们的应用程序或使用SpringJMS的方式,所以我创建了一个示例应用程序,该示例应用程序创建了3个连接工厂。 These factories are then used to create the message sent to a topic and two listeners within the same application (but as they are using a different connection factory and client ID these should be completely separate) but still both message listeners for the two connections are receiving the message. 然后使用这些工厂创建发送到主题的消息,并在同一应用程序中创建两个侦听器(但由于它们使用不同的连接工厂和客户端ID,因此它们应完全分开),但两个连接的两个消息侦听器仍在接收中消息。

I have tried running this against both HornetQ and Tibco and get the same outcome. 我已经尝试对HornetQ和Tibco进行此操作,并获得相同的结果。

message consumers created as follows in a class that implements MessageListener 在实现MessageListener的类中按以下方式创建的消息使用者

Connection connection = factory.createConnection(userName, password);
Session session = connection.createSession();
MessageConsumer topicReceiver = session.createSharedConsumer(topic, SUBSCRIPTION_NAME);
topicReceiver.setMessageListener(this);
connection.start();

Has anyone who has successfully used the shared consumers from JMS 2.0 point me in the direction of what I am missing? 成功使用过JMS 2.0共享用户的人是否向我指出了我所缺少的方向?

looks like I should have RTFM. 看起来我应该有RTFM。 From the JMS 2.0 spec: 根据JMS 2.0规范:

" A shared non-durable subscription is identified by a name specified by the client and by the client identifier if set. If the client identifier was set when the shared non-durable subscription was first created then a client which subsequently wishes to create a consumer on that shared non-durable subscription must use the same client identifier. " 共享的非持久订阅由客户端指定的名称和客户端标识符(如果已设置)标识。如果在首次创建共享的非持久订阅时设置了客户端标识符,则客户端随后希望创建使用者在该共享的非持久订阅上,必须使用相同的客户端标识符。

Therefore as multiple clients can not have the same client identifier you should not set the client identifier if you wish to use shared subscriptions (durable or non-durable). 因此,由于多个客户端不能具有相同的客户端标识符,因此,如果您希望使用共享订阅(持久或非持久),则不应设置客户端标识符。

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

相关问题 JMS主题发布/订阅者 - JMS Topic Publish/Subscriber JMS主题订户重新连接 - JMS topic subscriber reconnection 具有多个实例的群集中的JMS持久订阅者 - JMS durable subscriber in a cluster with multiple instances 无法使用 Spring 引导在 JMS 中配置持久订阅者 - Not able to configure durable subscriber in JMS with Spring Boot 在Jboss_EAP_7.0上为jms配置持久订户 - Configuring durable subscriber for jms topic on Jboss_EAP_7.0 一段时间后,JMS订阅者停止从主题获取消息 - JMS subscriber stops getting messages from topic after a while 如何使用 JMS Publisher 和 JMS Subscriber 为 JMeter 中的订阅者过滤来自 ActiveMQ 的响应消息 - How to filter response messages from ActiveMQ for subscribers in JMeter using JMS Publisher and JMS Subscriber 如何使用Spring JMS创建共享订阅 - How to create a shared subscription using spring JMS 当订阅者失败或停止从使用 JMS 的 activeMQ 中的主题接收消息时,有没有办法自动重新订阅? - Is there a way to auto re-subscription when subscriber fail or stops receiving message from a topic in activeMQ using JMS? Spring JMS 4.3.2 + Jboss EAP 6.4.8 + Webmethods Jms Broker 8.2 +持久共享主题订阅 - Spring JMS 4.3.2 + Jboss EAP 6.4.8 + Webmethods Jms Broker 8.2 + Durable shared topic subscription
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM