Class RabbitAmqpAdmin
java.lang.Object
org.springframework.amqp.rabbitmq.client.RabbitAmqpAdmin
- All Implemented Interfaces:
AmqpAdmin,Aware,BeanNameAware,ApplicationContextAware,ApplicationEventPublisherAware,Lifecycle,Phased,SmartLifecycle
@ManagedResource(description="Admin Tasks")
public class RabbitAmqpAdmin
extends Object
implements AmqpAdmin, ApplicationContextAware, ApplicationEventPublisherAware, BeanNameAware, SmartLifecycle
The
AmqpAdmin implementation for RabbitMQ AMQP 1.0 client.- Since:
- 4.0
- Author:
- Artem Bilan
-
Field Summary
FieldsFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeclareBinding(Binding binding) Declare a binding of a queue to an exchange.voiddeclareExchange(Exchange exchange) Declare an exchange.@Nullable QueueDeclare a queue whose name is automatically named.@Nullable StringdeclareQueue(Queue queue) Declare the given queue.booleandeleteExchange(String exchangeName) Delete an exchange.booleandeleteQueue(String queueName) Delete a queue, without regard for whether it is in use or has messages on it.voiddeleteQueue(String queueName, boolean unused, boolean empty) Delete a queue.@Nullable DeclarationExceptionEventintgetPhase()@Nullable QueueInformationgetQueueInfo(String queueName) Returns information about the queue, if it exists.@Nullable PropertiesgetQueueProperties(String queueName) Returns 4 propertiesRabbitAdmin.QUEUE_NAME,RabbitAdmin.QUEUE_MESSAGE_COUNT,RabbitAdmin.QUEUE_CONSUMER_COUNT,QUEUE_TYPE, or null if the queue doesn't exist.voidDeclares all the exchanges, queues and bindings in the enclosing application context, if any.booleanbooleanintpurgeQueue(String queueName) Purges the contents of the given queue.voidpurgeQueue(String queueName, boolean noWait) Purges the contents of the given queue.voidremoveBinding(Binding binding) Remove a binding of a queue to an exchange.voidsetApplicationContext(ApplicationContext applicationContext) voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetAutoStartup(boolean autoStartup) voidsetBeanName(String name) voidsetExplicitDeclarationsOnly(boolean explicitDeclarationsOnly) Set to true to only declareDeclarablebeans that are explicitly configured to be declared by this admin.voidsetIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions) voidsetTaskExecutor(TaskExecutor taskExecutor) Set a task executor to use for async operations.voidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.amqp.core.AmqpAdmin
getManualDeclarableSetMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable, stop
-
Field Details
-
QUEUE_TYPE
- See Also:
-
-
Constructor Details
-
RabbitAmqpAdmin
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
setBeanName
- Specified by:
setBeanNamein interfaceBeanNameAware
-
setIgnoreDeclarationExceptions
public void setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions) -
setTaskExecutor
Set a task executor to use for async operations. Currently only used withpurgeQueue(String, boolean).- Parameters:
taskExecutor- the executor to use.
-
setExplicitDeclarationsOnly
public void setExplicitDeclarationsOnly(boolean explicitDeclarationsOnly) Set to true to only declareDeclarablebeans that are explicitly configured to be declared by this admin.- Parameters:
explicitDeclarationsOnly- true to ignore beans with no admin declaration configuration.
-
getLastDeclarationExceptionEvent
- Returns:
- the last
DeclarationExceptionEventthat was detected in this admin.
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) -
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
start
-
stop
-
isRunning
-
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:
initializein interfaceAmqpAdmin
-
declareExchange
Description copied from interface:AmqpAdminDeclare an exchange.- Specified by:
declareExchangein interfaceAmqpAdmin- Parameters:
exchange- the exchange to declare.
-
deleteExchange
@ManagedOperation(description="Delete an exchange from the broker") public boolean deleteExchange(String exchangeName) Description copied from interface:AmqpAdminDelete 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:
deleteExchangein interfaceAmqpAdmin- Parameters:
exchangeName- the name of the exchange- Returns:
- true if the exchange existed and was deleted
-
declareQueue
Description copied from interface:AmqpAdminDeclare a queue whose name is automatically named. It is created with exclusive = true, autoDelete=true, and durable = false.- Specified by:
declareQueuein interfaceAmqpAdmin- Returns:
- The queue.
-
declareQueue
Description copied from interface:AmqpAdminDeclare the given queue.- Specified by:
declareQueuein interfaceAmqpAdmin- 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:AmqpAdminDelete a queue, without regard for whether it is in use or has messages on it.- Specified by:
deleteQueuein interfaceAmqpAdmin- 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:AmqpAdminDelete a queue.- Specified by:
deleteQueuein interfaceAmqpAdmin- 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:AmqpAdminPurges the contents of the given queue.- Specified by:
purgeQueuein interfaceAmqpAdmin- 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:AmqpAdminPurges the contents of the given queue.- Specified by:
purgeQueuein interfaceAmqpAdmin- Parameters:
queueName- the name of the queue.- Returns:
- the number of messages purged.
-
declareBinding
Description copied from interface:AmqpAdminDeclare a binding of a queue to an exchange.- Specified by:
declareBindingin interfaceAmqpAdmin- Parameters:
binding- a description of the binding to declare.
-
removeBinding
Description copied from interface:AmqpAdminRemove a binding of a queue to an exchange. Note unbindQueue/removeBinding was not introduced until 0.9 of the specification.- Specified by:
removeBindingin interfaceAmqpAdmin- 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 propertiesRabbitAdmin.QUEUE_NAME,RabbitAdmin.QUEUE_MESSAGE_COUNT,RabbitAdmin.QUEUE_CONSUMER_COUNT,QUEUE_TYPE, or null if the queue doesn't exist.- Specified by:
getQueuePropertiesin interfaceAmqpAdmin- Parameters:
queueName- the name of the queue.- Returns:
- the properties or null if the queue doesn't exist.
-
getQueueInfo
Description copied from interface:AmqpAdminReturns information about the queue, if it exists.- Specified by:
getQueueInfoin interfaceAmqpAdmin- Parameters:
queueName- the name of the queue.- Returns:
- the information or null if the queue doesn't exist.
-