[英]How to create a durable subscriber for a topic in WSO2 MB
I usr WSO2 MB 2.0.1,I tried to extend the JMS Java subscriber, provided at tutorial, to be a durable subscriber. 在usr WSO2 MB 2.0.1中,我尝试将教程中提供的JMS Java订户扩展为持久订户。 Then stop the jms client and send some messages to the topic. 然后停止jms客户端并向该主题发送一些消息。 But when I start the jms client, it does not receive the messages. 但是,当我启动jms客户端时,它不会收到消息。
Can some one let me know how to create a durable subscriber. 可以让我知道如何创建一个持久的订户。 My requirement is to receive the messages when the jms subscriber comes online. 我的要求是在jms订户联机时接收消息。
my code: public void subscribe(String topicName) { 我的代码:public void subscription(String topicName){
Properties initialContextProperties = new Properties();
initialContextProperties.put("java.naming.factory.initial",
"org.wso2.andes.jndi.PropertiesFileInitialContextFactory");
String connectionString = "amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672'";
initialContextProperties.put("connectionfactory.qpidConnectionfactory", connectionString);
initialContextProperties.put("topic.myWarning", "myWarning");
try {
InitialContext initialContext = new InitialContext(initialContextProperties);
TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory) initialContext.lookup("qpidConnectionfactory");
TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();
//topicConnection.setClientID("clientID");
topicConnection.start();
TopicSession topicSession =topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
//Topic topic = topicSession.createTopic(topicName);
Topic topic =(Topic) initialContext.lookup(topicName);
TopicSubscriber topicSubscriber =
topicSession.createDurableSubscriber(topic, "tom");
TextMessage receivedMessage = (TextMessage)topicSubscriber.receive();
System.out.println(receivedMessage);
// topicSubscriber.setMessageListener(new JCOMessageListener(
// topicConnection, topicSession, topicSubscriber));
} catch (NamingException e) {
e.printStackTrace();
} catch (JMSException e) {
e.printStackTrace();
}
}
Your JMS client is perfectly valid. 您的JMS客户端是完全有效的。
There has been a bug in durable topic subscriptions in WSO2 MB 2.0.1. WSO2 MB 2.0.1中的持久主题订阅中存在一个错误。 We have fixed that in WSO2 MB 2.1.1 version, which will be released within a month from today. 我们已经修复了WSO2 MB 2.1.1版本中的问题,该版本将从今天开始一个月内发布。
Thanks. 谢谢。
The link maybe help you, 该链接可能会帮助您,
Make Durable Topic Subscriptions Using WSO2 ESB 4.6.0 to WSO2 Message Broker 2.1.0 http://abeykoon.blogspot.tw/2013/04/make-durable-topic-subscriptions-using.html 使用WSO2 ESB 4.6.0到WSO2 Message Broker 2.1.0进行持久主题订阅http://abeykoon.blogspot.tw/2013/04/make-durable-topic-subscriptions-using.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.