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.

Implementing the Worker pattern in AMQP

Hi,
I'm trying to implement the Worker pattern using the Spring AMQP API and not making much headway.

Very simply, I want a queue like this:

Client sends a request -> Exchange -> routed to single Queue 'Q1'

Several Worker 'handlers' should peel off the requests from the queue and 'handle' them. Since the handling can take time, we want that the requests to be handled by the next available worker. So if a free worker is available, then the request is handled immediately, else it waits for a worker to get free.

Using the Spring AMQP API, I'm thinking I should set up a SimpleMessageListenerContainer on the 'Worker' side. However, that container only allows me to set one 'Listener' on it.
How can I make is so that I can have a variable number of listeners and that they are cycled as described above?

Comment

No, JMX on the listener container just exposes the active consumer count as a read-only attribute; see the @ManagedMetric annotation on getActiveConsumerCount().

The AMQP listener container does not currently support dynamic modification of the concurrency. Nor does it support auto resizing the consumers between a min and max (like the JMS listener container does).