This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Dynamic creation of multiple JMS listeners to many queuesPage Title Module

Dynamic creation of multiple JMS listeners to many queues

Jun 28th, 2007, 09:30 AM

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.

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

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.

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)