Announcement Announcement Module
Collapse
No announcement yet.
Dynamic creation of multiple JMS listeners to many queues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic creation of multiple JMS listeners to many queues

    Hi Springers,


    I wonder if it is possible to have multiple JMS listeners in a dynamic fashion; the problem Iím facing is that before starting Spring I must read from a DB the queues that I need listen to: as you can imagine itís not possible to neither know beforehand the number of queues nor their names.

    So, having something like:

    <bean id="listenerContainer"
    class="org.springframework.jms.listener.DefaultMes sageListenerContainer102">
    <property name="concurrentConsumers"><value>${threads.number }</value></property>
    <property name="destinationName"><value>${queue.main}</value></property>
    <property name="connectionFactory" ref="connectionFactory" />
    <property name="messageListener" ref="messageListener" />
    <property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
    <property name="sessionTransacted" value="true"/>
    </bean>


    Is not going to work, the snippet above will create a pooled listener that works on ONE AND ONLY ONE queue.


    Please assist. Thanks in advanced!

  • #2
    Hello,

    i think you have to create the MessageListenerContainer programmatically. You can defined a MessageListenerContainer as a prototype bean (without autostart enebaled). After that you can fetch the prototype, and configure it.

    Hope this helps

    Best regards
    agim

    Comment


    • #3
      I wonder if you could provide a little example about how to do that; even if it is not related to JMS but something I could use as a reference in order to understand how to implement the prototype and the autostart disabled.

      Thanks in advanced!

      Comment


      • #4
        OK, I understand now what you meant:

        AbstractJmsListeningContainer -> setAutoStartup


        And prototype definition of the bean.


        Thanks!

        Comment


        • #5
          hi,

          were you able to implement the above ? Can you please share your code , how you manged to do this. I have a similar requirement.

          thanks

          Comment


          • #6
            Hi,

            At the end the requirements changed and never implemented that idea, however the idea was to create a prototype definition (http://www.springframework.org/docs/...opes-prototype) of a AbstractJmsListeningContainer bean (http://www.springframework.org/docs/...Container.html)
            with the property autoStartup set to false, so no listeners are initialized at Spring's startup.

            So, you read the list of queues you need to listen to, then you create as many beans as needed usuing the prototype bean, you set the queues to its respective bean and initialize the listeners (start or doStart, test the correct one)

            I think that could work.

            Best wishes...

            Comment

            Working...
            X