Results 1 to 6 of 6

Thread: SimpleMessageListenerContainer

  1. #1
    Join Date
    Jun 2012
    Posts
    11

    Default 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. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,014

    Default

    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.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Jun 2012
    Posts
    11

    Default

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

  4. #4
    Join Date
    May 2013
    Posts
    2

    Default

    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?

  5. #5
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,014

    Default

    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).
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  6. #6
    Join Date
    May 2013
    Posts
    2

    Default

    Ah, quite simple really. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •