Spring container for listening to JMS messages

I am new to JMS and am working on setting up ActiveMQ with Tomcat 6 and Spring. I have most of the basic settings, but I'm a little confused with the containers for listening to the messages that Spring provides. Reading the documentation looks like the message listener container is used to β€œprocess” the subscription (I work with topics), unsubscribe, and deliver the message to the listener. I am not sure if I think about it correctly. If this is the case, I do not see any documentation about how several classes would subscribe to the same topic using the message listener container. I see that you can set the messageListener property, but this will only allow one class to subscribe to the topic. It does not seem to create another instance of one container of the message listener just so that the other party (Message Driven POJO) listens to the same topic.

Can anyone shed some light on this for me? I seem a little confused.

Thanks in advance!

+6
java spring tomcat jms activemq
source share
3 answers

If you are familiar with EJB managed messages, then Spring MessageListenerContainer effectively replaces MDB. It gets its name because it is connected to a JMS subject / queue, as well as one JMS MessageListener, and it disconnects messages from this topic / queue and passes them to the MessageListener.

You are absolutely right that only one MessageListener can be registered in each container at a time, but consider that although the MessageListenerContainer code can be quite complex, it is actually a very lightweight runtime component. Do not be afraid to create multiple instances.

Also, make sure you select the appropriate MessageListener implementation for your situation. The simple and standard implementation is actually completely different, but none of them are "better."

+4
source share

The guys are true that a few containers will help you, but this seems like the wrong approach. Since the goal of JMS is to integrate various applications / services, not internal application processes (several classes you are talking about). I would suggest a push message for different classes on my own after receiving them through a Message Listener. Otherwise, you will look at frameworks such as Apache Camel or Spring Integration.

+2
source share

A container is a wrapper for "adapting" any POJO to receive messages from a queue or topic. If you want to use multiple listeners, you will get multiple containers.

0
source share

All Articles