Search code examples
javajmsspring-jms

Task distribution using Spring JMS receiving


I am trying to receive JMS messages from a JMS queue. On receiving messages they are forwarded to different servers for processing.

I want to instantiate Message Listeners with information about server it is communicating with and process status.

Using available Spring Message Listener Container Classes only a single stateless instance of Message Listener can be created which is used with multiple threads.

Is there a solution for adding multiple instances of Message Listener to Message Listener Container?


Solution

  • Spring's MessageListenerContainers are designed to only hold one MessageListener and run multiple threads through them, in the same way that multiple threads run through a servlet instance.

    A way that you could implement what you are talking about is register the one MessageListener, and have it act as a facade to a set of other listeners that you instantiate into it, and have the facade forward requests to them.