You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by go canal <go...@yahoo.com> on 2010/04/11 08:04:20 UTC
dynamic topic and listener
Hello,
googled but still can not get detailed enough info.
my use case is that a chat room needs to be dynamically created, so a dynamic listener.
how do I do this in Java ?
http://activemq.apache.org/how-do-i-create-new-destinations.html mentioned that we can use session.createTopic() to create a dynamic topic. So I assume that we can first have a static queue newChatRoom, with a listener who will create the dynamic topic:
public void onMessage(Message message, Session session) throws JMSException {
Topic topic = session.createTopic ("newTopic");
}
But how do I register a new listener for this dynamic topic ?
Another question, how do I delete the topic when all people left the room ?
rgds,
canal
Re: dynamic topic and listener
Posted by go canal <go...@yahoo.com>.
I cannot receive the messages:
TemporaryTopic topic = session.createTemporaryTopic();
// topic name is something like this:
// ID:lchu-2087-1271131089285-2:0:1
MessageConsumer consumer = session.createConsumer(topic);
consumer.setMessageListener(this);
Looking at server side log message, MessageListenerServlet received the msg but the listener did not.
Any idea ?
rgds,
canal
________________________________
From: go canal <go...@yahoo.com>
To: users@activemq.apache.org
Sent: Mon, April 12, 2010 6:32:42 PM
Subject: Re: dynamic topic and listener
I guess:
- to be able to delete the Topic/Queue, I should create the temporaryTopic/temporaryQueue
- then create the MessageConsumer:
consumer = session.createConsumer (topic);
- set the lsitener
consumer.setMessageListener (this);
Am I correct ?
rgds,
canal
________________________________
From: go canal <go...@yahoo.com>
To: users@activemq.apache.org
Sent: Sun, April 11, 2010 2:04:20 PM
Subject: dynamic topic and listener
Hello,
googled but still can not get detailed enough info.
my use case is that a chat room needs to be dynamically created, so a dynamic listener.
how do I do this in Java ?
http://activemq.apache.org/how-do-i-create-new-destinations.html mentioned that we can use session.createTopic() to create a dynamic topic. So I assume that we can first have a static queue newChatRoom, with a listener who will create the dynamic topic:
public void onMessage(Message message, Session session) throws JMSException {
Topic topic = session.createTopic ("newTopic");
}
But how do I register a new listener for this dynamic topic ?
Another question, how do I delete the topic when all people left the room ?
rgds,
canal
Re: dynamic topic and listener
Posted by go canal <go...@yahoo.com>.
I guess:
- to be able to delete the Topic/Queue, I should create the temporaryTopic/temporaryQueue
- then create the MessageConsumer:
consumer = session.createConsumer (topic);
- set the lsitener
consumer.setMessageListener (this);
Am I correct ?
rgds,
canal
________________________________
From: go canal <go...@yahoo.com>
To: users@activemq.apache.org
Sent: Sun, April 11, 2010 2:04:20 PM
Subject: dynamic topic and listener
Hello,
googled but still can not get detailed enough info.
my use case is that a chat room needs to be dynamically created, so a dynamic listener.
how do I do this in Java ?
http://activemq.apache.org/how-do-i-create-new-destinations.html mentioned that we can use session.createTopic() to create a dynamic topic. So I assume that we can first have a static queue newChatRoom, with a listener who will create the dynamic topic:
public void onMessage(Message message, Session session) throws JMSException {
Topic topic = session.createTopic ("newTopic");
}
But how do I register a new listener for this dynamic topic ?
Another question, how do I delete the topic when all people left the room ?
rgds,
canal