Announcement Announcement Module
Collapse
No announcement yet.
SimpleMessageListenerContainer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleMessageListenerContainer

    Hi,

    I am new to messaging system and have queries on SimpleMessageListenerContainer. Actually our team is developing a messaging system using RabbitMQ, but now we want to take benefits of Spring AMQP, so we have decided to do some prototyping.

    Queries (My questions may be irrelevant because I am new to this topic, so please ........ )

    Can I have multiple SimpleMessageListenerContainer's in my application context?

    Can I add more than one "Message-driven POJO" (aka Delegate/Handler/Actual Consumer) in SimpleMessageListenerContainer?

    Can I do something like configuring multiple Consumers with one Queue?

    Thanks
    Kaps

  • #2
    Welcome!

    There is no limit to how many listener containers you have in a context; each container has 1 listener; the container can be configured to receive messages from a list of queues (or just one).

    Each container can be configured with more than one consumer - setConcurrentConsumers(); your listener must be stateless, or at least be coded to handle multiple threads if you have more than one consumer.

    I hope that answers your questions.

    Comment


    • #3
      Thanks a lot Gary, yes I got answers to my questions.

      Comment


      • #4
        I'm confused about this answer. I can see that programmatically the listener container only allows a single listener to be set on the container but in the app context it supports multiple listeners e.g

        Code:
            <rabbit:listener-container id="listenerContainer"  connection-factory="connectionFactory"  message-converter="jsonMessageConverter" >
                <rabbit:listener queues="msg.consumer" ref="consumerHandler" method="handleIt" />
                <rabbit:listener queues="msg.square" ref="squareHandler" method="handleSquare" />
            </rabbit:listener-container>
        And this does appear to work. Can you explain?

        Comment


        • #5
          The namespaces is simply a convenience - a shortcut for making configuration easier.

          While it "looks" like this is a single container with multiple listeners, it actually generates a container for each listener, with each container using the same "common" configuration declared at the top element level (connection factory etc).

          Comment


          • #6
            Ah, quite simple really. Thanks

            Comment

            Working...
            X