• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

ActiveMQ dynamic queues

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks dave for letting us know the problem
 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic