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

  • Exclusive Message Consumer

    How does one go about setting up an exclusive message consumer? I am using a SimpleMessageListenerContainer for async message reception and can't figure out how to do it.


    I had set-up RabbitMQ and wanted to create a queue from which only one consumer can take messages. I figured I would make the Queue exclusive. I also wanted the Queue to be durable (survive RabbitMQ server restarts) so I also set that property on the Queue. So after the Queue was created and I restarted the ActiveMQ server, the Queue did not get re-registered on the server and the SimpleMessageListenerContainer I had created began logging the following exception:

    Code:
    Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no queue 'sample_tt' in vhost '/', class-id=50, method-id=10),null,""}
    I was trying to figure out what had happened and stumbled on this thread.

    So it looks like I didn't fully understand what an exclusive queue really is. The thread mentions to use 'exclusive=true' in the 'basic.consume' method. I combed through the Spring source to determine where this is called.

    The SimpleMessageListenerContainer uses a Set of BlockingQueueConsumer and when the start() method executes on a BlockingQueueConsumer, there is a call to com.rabbitmq.client.impl.ChannelN#basicConsume method in the RabbitMQ Java client.

    That call eventually continues on to call an overloaded basicConsume() method that takes a boolean variable called 'exclusive' indicating that the consumer of messages from the given queue is the only one able to consume messages from that queue. However, the version of that method used by BlockingQueueConsumer uses 'exclusive=false'.

    In short, I want to create a queue that will survive a RabbitMQ server restart and from which only one message consumer can consume.
    Last edited by CAL5101; Mar 6th, 2012, 04:45 PM. Reason: Updated description

  • #2
    Can you explain the question in a bit more detail?

    If you mean 'exclusive' at the queue level, that is a parameter of the Queue declaration.

    If you mean 'exclusive' as in 'only one', there is a concurrent-consumers setting (but I think the default is 1).

    Comment


    • #3
      I updated the original post with more details.

      Comment

      Working...
      X