Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActiveMQ dynamic queues

 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dave for letting us know the problem
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic