Announcement Announcement Module
No announcement yet.
jmsTemplate + add listener to listener container Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • jmsTemplate + add listener to listener container

    I'm newbie with Apache ActiveMQ and
    I've started using 5.8.0 release + Spring

    I want that every session created in a servlet container ( Tomcat ), subscribes itself as consumer/listener for message from a Topic ( created into JMS broker by an admin )

    I've got some questions:

    If I've got a listener container as

    <jms:listener-container concurrency="10" >
    <jms:listener id="QueueListener" destination="Queue.Name" ref="queueListener" />


    Can I add <jms:listener> ( a.k.a MessageListener ) to Listener Container on runtime ?
    I want to add one listener per web session
    How ?


    If I can't,

    Can I create a Consumer on runtime and set a MessageListener for it by using jmsTemplate?
    I tried to do it with JMS API in jmsTemplate.execute() with SessionCallback,
    And a Consumer is created but MessageListener never is called and message is never consumed from Topic.

    Why ? How ?


    If I can't ,

    If I use PooledConnectionFactory + JMS API ( no listener-container )
    do I need to close Connection objects and release Consumers/Producers by hand ?

    Remember I want to create a Consumer per session


    Is there other way to do all these things on an easy mode ?

    Thanks and regards

  • #2
    The <jms:listener/> is just a convenience.

    In fact each such element gets its own listener container (sharing the configuration elements from the <jms:listener-container/> parent element). You are not really "adding" a listener to a single container.

    So, you can simply spin-up a new 'DefaultMessageListenerContainer' for each destination on demand.