Meaningless Drivel is fun!*
The moose likes EJB and other Java EE Technologies and the fly likes ActiveMQ dynamic queues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ActiveMQ dynamic queues" Watch "ActiveMQ dynamic queues" New topic
Author

ActiveMQ dynamic queues

dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Hi,

With ActiveMQ, one can create a queue (or topic) on the fly, which is pretty cool. But I'm wondering if the queue can actually be created by a Consumer rather than a Producer.

Specifically, here's the issue I'm having. On application startup, I initialize a class that implements MessageListener and registers itself like this:



later on, a producer creates a queue also called "unique-subject" and places a message on it. What happens is the first time after I restart ActiveMQ, my MessageListener's onMessage() method is never called. However, when I subsequently run the application, onMessage() is in fact called (as long as I don't restart ActiveMQ).

This makes me think that the MessageListener is not being properly bound until the queue is created by a Producer. Is that how ActiveMQ actually behaves, or is this likely my error?

Thanks in advance.


Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Just calling the createQueue creates a queue dynamically.

http://activemq.apache.org/how-do-i-create-new-destinations.html

If it is not working for you someone from ActiveMQ forum may be able to help you.


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

You can check the detsinations created either using JMX or Active MQ API
http://activemq.apache.org/how-can-i-see-what-destinations-are-used.html
dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Thanks, Pradip. I basically just needed confirmation that my understanding about ActiveMQ was correct. There must be user-error (i.e. me) somewhere.
dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
In case anyone else is having a similar issue, my problem seemed to stem from my not committing the Session after creating & adding the MessageListener. Once I added after

, my MessageListener immediately began receiving onMessage() notifications.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Thanks dave for letting us know the problem
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Hi I was also trying to create a topic on the fly, but somehow it's giving following error.

"JNDI API lookup failed: javax.naming.NameNotFoundException: myTopic"


Here is my code.



Here is my jndi.properties file.



Can anybody explain what's wrong with this code? I am a newbie in JMS


FYI, I took this code from here


The Best way to predict your future is to create it - Every great individual common man
 
 
subject: ActiveMQ dynamic queues