public class RabbitAdmin extends java.lang.Object implements AmqpAdmin, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
| Modifier and Type | Field and Description |
|---|---|
private org.springframework.context.ApplicationContext |
applicationContext |
private boolean |
autoStartup |
private ConnectionFactory |
connectionFactory |
protected static java.lang.String |
DEFAULT_EXCHANGE_NAME |
private boolean |
ignoreDeclarationExceptions |
private java.lang.Object |
lifecycleMonitor |
protected org.apache.commons.logging.Log |
logger
Logger available to subclasses
|
protected static java.lang.Object |
QUEUE_CONSUMER_COUNT |
protected static java.lang.Object |
QUEUE_MESSAGE_COUNT |
protected static java.lang.Object |
QUEUE_NAME |
private RabbitTemplate |
rabbitTemplate |
private boolean |
running |
| Constructor and Description |
|---|
RabbitAdmin(ConnectionFactory connectionFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
If
autoStartup is set to true, registers a callback on the
ConnectionFactory to declare all exchanges and queues in the enclosing application context. |
void |
declareBinding(Binding binding)
Declare a binding of a queue to an exchange.
|
private void |
declareBindings(com.rabbitmq.client.Channel channel,
Binding... bindings) |
void |
declareExchange(Exchange exchange)
Declare an exchange
|
private void |
declareExchanges(com.rabbitmq.client.Channel channel,
Exchange... exchanges) |
Queue |
declareQueue()
Declares a server-named exclusive, autodelete, non-durable queue.
|
java.lang.String |
declareQueue(Queue queue)
Declare the given queue.
|
private com.rabbitmq.client.AMQP.Queue.DeclareOk[] |
declareQueues(com.rabbitmq.client.Channel channel,
Queue... queues) |
boolean |
deleteExchange(java.lang.String exchangeName)
Delete an exchange.
|
boolean |
deleteQueue(java.lang.String queueName)
Delete a queue, without regard for whether it is in use or has messages on it
|
void |
deleteQueue(java.lang.String queueName,
boolean unused,
boolean empty)
Delete a queue
|
private <T extends Declarable> |
filterDeclarables(java.util.Collection<T> declarables)
Remove any instances that should not be declared by this admin.
|
java.util.Properties |
getQueueProperties(java.lang.String queueName)
Returns 3 properties
QUEUE_NAME, QUEUE_MESSAGE_COUNT,
QUEUE_CONSUMER_COUNT, or null if the queue doesn't exist. |
RabbitTemplate |
getRabbitTemplate() |
void |
initialize()
Declares all the exchanges, queues and bindings in the enclosing application context, if any.
|
boolean |
isAutoStartup() |
private boolean |
isDeclaringDefaultExchange(Exchange exchange) |
private boolean |
isDeclaringImplicitQueueBinding(Binding binding) |
private boolean |
isDefaultExchange(java.lang.String exchangeName) |
private boolean |
isDeletingDefaultExchange(java.lang.String exchangeName) |
private boolean |
isImplicitQueueBinding(Binding binding) |
private boolean |
isRemovingImplicitQueueBinding(Binding binding) |
void |
purgeQueue(java.lang.String queueName,
boolean noWait)
Purges the contents of the given queue.
|
void |
removeBinding(Binding binding)
Remove a binding of a queue to an exchange.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setAutoStartup(boolean autoStartup) |
void |
setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions) |
protected static final java.lang.String DEFAULT_EXCHANGE_NAME
protected static final java.lang.Object QUEUE_NAME
protected static final java.lang.Object QUEUE_MESSAGE_COUNT
protected static final java.lang.Object QUEUE_CONSUMER_COUNT
protected final org.apache.commons.logging.Log logger
private final RabbitTemplate rabbitTemplate
private volatile boolean running
private volatile boolean autoStartup
private volatile org.springframework.context.ApplicationContext applicationContext
private volatile boolean ignoreDeclarationExceptions
private final java.lang.Object lifecycleMonitor
private final ConnectionFactory connectionFactory
public RabbitAdmin(ConnectionFactory connectionFactory)
public void setAutoStartup(boolean autoStartup)
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwarepublic void setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions)
public RabbitTemplate getRabbitTemplate()
public void declareExchange(Exchange exchange)
AmqpAdmindeclareExchange in interface AmqpAdminexchange - the exchange to declare.@ManagedOperation public boolean deleteExchange(java.lang.String exchangeName)
AmqpAdmindeleteExchange in interface AmqpAdminexchangeName - the name of the exchange@ManagedOperation public java.lang.String declareQueue(Queue queue)
declareQueue in interface AmqpAdminqueue - the queue to declare@ManagedOperation public Queue declareQueue()
declareQueue in interface AmqpAdmin@ManagedOperation public boolean deleteQueue(java.lang.String queueName)
AmqpAdmindeleteQueue in interface AmqpAdminqueueName - the name of the queue@ManagedOperation
public void deleteQueue(java.lang.String queueName,
boolean unused,
boolean empty)
AmqpAdmindeleteQueue in interface AmqpAdminqueueName - the name of the queueunused - true if the queue should be deleted only if not in useempty - true if the queue should be deleted only if empty@ManagedOperation
public void purgeQueue(java.lang.String queueName,
boolean noWait)
AmqpAdminpurgeQueue in interface AmqpAdminqueueName - the name of the queuenoWait - true to not await completion of the purge@ManagedOperation public void declareBinding(Binding binding)
AmqpAdmindeclareBinding in interface AmqpAdminbinding - a description of the binding to declare.@ManagedOperation public void removeBinding(Binding binding)
AmqpAdminremoveBinding in interface AmqpAdminbinding - a description of the binding to remove.public java.util.Properties getQueueProperties(java.lang.String queueName)
QUEUE_NAME, QUEUE_MESSAGE_COUNT,
QUEUE_CONSUMER_COUNT, or null if the queue doesn't exist.getQueueProperties in interface AmqpAdminqueueName - the name of the queue.public boolean isAutoStartup()
public void afterPropertiesSet()
autoStartup is set to true, registers a callback on the
ConnectionFactory to declare all exchanges and queues in the enclosing application context. If the
callback fails then it may cause other clients of the connection factory to fail, but since only exchanges,
queues and bindings are declared failure is not expected.afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanInitializingBean.afterPropertiesSet(),
initialize()public void initialize()
private <T extends Declarable> java.util.Collection<T> filterDeclarables(java.util.Collection<T> declarables)
declarables - the collection of Declarables.Declarables that should be declared by this
admin.private void declareExchanges(com.rabbitmq.client.Channel channel,
Exchange... exchanges)
throws java.io.IOException
java.io.IOExceptionprivate com.rabbitmq.client.AMQP.Queue.DeclareOk[] declareQueues(com.rabbitmq.client.Channel channel,
Queue... queues)
throws java.io.IOException
java.io.IOExceptionprivate void declareBindings(com.rabbitmq.client.Channel channel,
Binding... bindings)
throws java.io.IOException
java.io.IOExceptionprivate boolean isDeclaringDefaultExchange(Exchange exchange)
private boolean isDeletingDefaultExchange(java.lang.String exchangeName)
private boolean isDefaultExchange(java.lang.String exchangeName)
private boolean isDeclaringImplicitQueueBinding(Binding binding)
private boolean isRemovingImplicitQueueBinding(Binding binding)
private boolean isImplicitQueueBinding(Binding binding)