Results 1 to 4 of 4

Thread: message selector using SimpleMessageListenerContainer

  1. #1
    Join Date
    Nov 2012
    Posts
    4

    Default message selector using SimpleMessageListenerContainer

    Hi,

    I was wondering if someone can tell how to use message selector with SimpleMessageListenerContainer...I want to pick up messages according to some criteria. I could not find any property on container to set. Please let me know how can I do this.

    thank you,
    -raj

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

    Default

    Unlike JMS, AMQP/RabbitMQ doesn't support message selectors.

    One technique you can use to provide similar functionality is to use a topic exchange, together with routing keys that can be used by clients to bind specific patterns for their queue.

    For example, 2 messages with routing keys 'foo.bar' and 'foo.baz'. A queue can be bound with pattern 'foo.*' and he will get both messages, but queues bound with"foo.bar" and "foo.baz" will only get one message each.

    There are lots of tutorials on the 'net about using topic exchanges.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Nov 2012
    Posts
    4

    Default

    Thanks Gary for quick response. Actually, the selection criteria is known only at runtime so I won't be able to configure the queues upfront. I might have to create queues, then configure/start SimpleMessageListenerContainer to that queue, and once done stop/shutdown the listener, and delete the queue.

    But I was wondering who would I find out that this listener is done consuming all messages and is ok to shutdown. i.e. the queue is empty now.

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,029

    Default

    You can dynamically declare/bind queues whenever you want.

    No, there's no AMQP API to detect an empty queue; but RabbitMQ does have a REST API which you can use to find that information.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

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