Results 1 to 4 of 4

Thread: API methods for checking if Queue and Exchange exists already?

  1. #1
    Join Date
    Feb 2011
    Posts
    12

    Default 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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    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

  3. #3
    Join Date
    Feb 2011
    Posts
    12

    Default

    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

  4. #4
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    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).

Posting Permissions

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