Class RabbitAmqpAdmin

java.lang.Object
org.springframework.amqp.rabbitmq.client.RabbitAmqpAdmin
All Implemented Interfaces:
AmqpAdmin, Aware, BeanNameAware, ApplicationContextAware, ApplicationEventPublisherAware, Lifecycle, Phased, SmartLifecycle

The AmqpAdmin implementation for RabbitMQ AMQP 1.0 client.
Since:
4.0
Author:
Artem Bilan
  • Field Details

  • Constructor Details

    • RabbitAmqpAdmin

      public RabbitAmqpAdmin(com.rabbitmq.client.amqp.Connection amqpConnection)
  • Method Details

    • setApplicationContext

      public void setApplicationContext(ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface ApplicationContextAware
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface ApplicationEventPublisherAware
    • setBeanName

      public void setBeanName(String name)
      Specified by:
      setBeanName in interface BeanNameAware
    • setIgnoreDeclarationExceptions

      public void setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions)
    • setTaskExecutor

      public void setTaskExecutor(TaskExecutor taskExecutor)
      Set a task executor to use for async operations. Currently only used with purgeQueue(String, boolean).
      Parameters:
      taskExecutor - the executor to use.
    • setExplicitDeclarationsOnly

      public void setExplicitDeclarationsOnly(boolean explicitDeclarationsOnly)
      Set to true to only declare Declarable beans that are explicitly configured to be declared by this admin.
      Parameters:
      explicitDeclarationsOnly - true to ignore beans with no admin declaration configuration.
    • getLastDeclarationExceptionEvent

      public @Nullable DeclarationExceptionEvent getLastDeclarationExceptionEvent()
      Returns:
      the last DeclarationExceptionEvent that was detected in this admin.
    • isAutoStartup

      public boolean isAutoStartup()
      Specified by:
      isAutoStartup in interface SmartLifecycle
    • setAutoStartup

      public void setAutoStartup(boolean autoStartup)
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface Phased
      Specified by:
      getPhase in interface SmartLifecycle
    • start

      public void start()
      Specified by:
      start in interface Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • initialize

      public void initialize()
      Declares all the exchanges, queues and bindings in the enclosing application context, if any. It should be safe (but unnecessary) to call this method more than once.
      Specified by:
      initialize in interface AmqpAdmin
    • declareExchange

      public void declareExchange(Exchange exchange)
      Description copied from interface: AmqpAdmin
      Declare an exchange.
      Specified by:
      declareExchange in interface AmqpAdmin
      Parameters:
      exchange - the exchange to declare.
    • deleteExchange

      @ManagedOperation(description="Delete an exchange from the broker") public boolean deleteExchange(String exchangeName)
      Description copied from interface: AmqpAdmin
      Delete an exchange. Look at implementation specific subclass for implementation specific behavior, for example for RabbitMQ this will delete the exchange without regard for whether it is in use or not.
      Specified by:
      deleteExchange in interface AmqpAdmin
      Parameters:
      exchangeName - the name of the exchange
      Returns:
      true if the exchange existed and was deleted
    • declareQueue

      public @Nullable Queue declareQueue()
      Description copied from interface: AmqpAdmin
      Declare a queue whose name is automatically named. It is created with exclusive = true, autoDelete=true, and durable = false.
      Specified by:
      declareQueue in interface AmqpAdmin
      Returns:
      The queue.
    • declareQueue

      public @Nullable String declareQueue(Queue queue)
      Description copied from interface: AmqpAdmin
      Declare the given queue.
      Specified by:
      declareQueue in interface AmqpAdmin
      Parameters:
      queue - the queue to declare.
      Returns:
      the name of the queue.
    • deleteQueue

      @ManagedOperation(description="Delete a queue from the broker") public boolean deleteQueue(String queueName)
      Description copied from interface: AmqpAdmin
      Delete a queue, without regard for whether it is in use or has messages on it.
      Specified by:
      deleteQueue in interface AmqpAdmin
      Parameters:
      queueName - the name of the queue.
      Returns:
      true if the queue existed and was deleted.
    • deleteQueue

      @ManagedOperation(description="Delete a queue from the broker if unused and empty (when corresponding arguments are true") public void deleteQueue(String queueName, boolean unused, boolean empty)
      Description copied from interface: AmqpAdmin
      Delete a queue.
      Specified by:
      deleteQueue in interface AmqpAdmin
      Parameters:
      queueName - the name of the queue.
      unused - true if the queue should be deleted only if not in use.
      empty - true if the queue should be deleted only if empty.
    • purgeQueue

      @ManagedOperation(description="Purge a queue and optionally don't wait for the purge to occur") public void purgeQueue(String queueName, boolean noWait)
      Description copied from interface: AmqpAdmin
      Purges the contents of the given queue.
      Specified by:
      purgeQueue in interface AmqpAdmin
      Parameters:
      queueName - the name of the queue.
      noWait - true to not await completion of the purge.
    • purgeQueue

      @ManagedOperation(description="Purge a queue and return the number of messages purged") public int purgeQueue(String queueName)
      Description copied from interface: AmqpAdmin
      Purges the contents of the given queue.
      Specified by:
      purgeQueue in interface AmqpAdmin
      Parameters:
      queueName - the name of the queue.
      Returns:
      the number of messages purged.
    • declareBinding

      public void declareBinding(Binding binding)
      Description copied from interface: AmqpAdmin
      Declare a binding of a queue to an exchange.
      Specified by:
      declareBinding in interface AmqpAdmin
      Parameters:
      binding - a description of the binding to declare.
    • removeBinding

      public void removeBinding(Binding binding)
      Description copied from interface: AmqpAdmin
      Remove a binding of a queue to an exchange. Note unbindQueue/removeBinding was not introduced until 0.9 of the specification.
      Specified by:
      removeBinding in interface AmqpAdmin
      Parameters:
      binding - a description of the binding to remove.
    • getQueueProperties

      @ManagedOperation(description="Get queue name, message count and consumer count") public @Nullable Properties getQueueProperties(String queueName)
      Returns 4 properties RabbitAdmin.QUEUE_NAME, RabbitAdmin.QUEUE_MESSAGE_COUNT, RabbitAdmin.QUEUE_CONSUMER_COUNT, QUEUE_TYPE, or null if the queue doesn't exist.
      Specified by:
      getQueueProperties in interface AmqpAdmin
      Parameters:
      queueName - the name of the queue.
      Returns:
      the properties or null if the queue doesn't exist.
    • getQueueInfo

      public @Nullable QueueInformation getQueueInfo(String queueName)
      Description copied from interface: AmqpAdmin
      Returns information about the queue, if it exists.
      Specified by:
      getQueueInfo in interface AmqpAdmin
      Parameters:
      queueName - the name of the queue.
      Returns:
      the information or null if the queue doesn't exist.