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

  • message selector using SimpleMessageListenerContainer


    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,

  • #2
    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 '' and 'foo.baz'. A queue can be bound with pattern 'foo.*' and he will get both messages, but queues bound with"" and "foo.baz" will only get one message each.

    There are lots of tutorials on the 'net about using topic exchanges.


    • #3
      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
        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.