Announcement Announcement Module
Collapse
No announcement yet.
API methods for checking if Queue and Exchange exists already? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • API methods for checking if Queue and Exchange exists already?

    Hi,

    In Spring-AMQP, please let me know if there are any API methods for the following:

    1. To check if a Queue already exists (using queue name).
    2. To check if Exchange already exists (using exchange name).


    Thanks in Advance..
    Sam

  • #2
    RabbitAdmin provides declareQueue and declareExchange methods. Those are idempotent, so even if the Queue or Exchange already exists, it's safe to call those methods. Does that match your use-case, or are you trying to do something different... such as when the Queue does not exist, prevent something?

    -Mark

    Comment


    • #3
      Thanks for ther response Mark.

      My requirement is that, I have to delete a queue with the queue name (using amqpAdmin.deleteQueue(queueName) method). So I need to check if there is already a queue existing with that queueName.

      Is there any API methods that fulfills this functionality (say like isQueueExists(name), etc...)..

      Thanks in Advance
      - Sam

      Comment


      • #4
        RabbitAdmin.delete*() will return false if the Queue/Exchange did not exist, since the broker will raise an exception in that case. If you need more fine grained control there is always the execute() method in RabbitTemplate, and the underlying API (e.g. Channel.queueDeclarePassive).

        Comment

        Working...
        X