public class RabbitAdmin extends Object implements AmqpAdmin, ApplicationContextAware, ApplicationEventPublisherAware, InitializingBean
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_EXCHANGE_NAME
The default exchange name.
|
protected org.apache.commons.logging.Log |
logger
Logger available to subclasses
|
static Object |
QUEUE_CONSUMER_COUNT
Property key for the consumer count in the
Properties returned by
getQueueProperties(String) . |
static Object |
QUEUE_MESSAGE_COUNT
Property key for the message count in the
Properties returned by
getQueueProperties(String) . |
static Object |
QUEUE_NAME
Property key for the queue name in the
Properties returned by
getQueueProperties(String) . |
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.
|
void |
declareExchange(Exchange exchange)
Declare an exchange
|
Queue |
declareQueue()
Declares a server-named exclusive, autodelete, non-durable queue.
|
String |
declareQueue(Queue queue)
Declare the given queue.
|
boolean |
deleteExchange(String exchangeName)
Delete an exchange.
|
boolean |
deleteQueue(String queueName)
Delete a queue, without regard for whether it is in use or has messages on it
|
void |
deleteQueue(String queueName,
boolean unused,
boolean empty)
Delete a queue
|
DeclarationExceptionEvent |
getLastDeclarationExceptionEvent() |
Properties |
getQueueProperties(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() |
void |
purgeQueue(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(ApplicationContext applicationContext) |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setAutoStartup(boolean autoStartup) |
void |
setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions) |
public static final String DEFAULT_EXCHANGE_NAME
public static final Object QUEUE_NAME
Properties
returned by
getQueueProperties(String)
.public static final Object QUEUE_MESSAGE_COUNT
Properties
returned by
getQueueProperties(String)
.public static final Object QUEUE_CONSUMER_COUNT
Properties
returned by
getQueueProperties(String)
.protected final org.apache.commons.logging.Log logger
public RabbitAdmin(ConnectionFactory connectionFactory)
public void setAutoStartup(boolean autoStartup)
public void setApplicationContext(ApplicationContext applicationContext)
setApplicationContext
in interface ApplicationContextAware
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
public void setIgnoreDeclarationExceptions(boolean ignoreDeclarationExceptions)
public DeclarationExceptionEvent getLastDeclarationExceptionEvent()
DeclarationExceptionEvent
that was detected in this admin.public RabbitTemplate getRabbitTemplate()
public void declareExchange(Exchange exchange)
AmqpAdmin
declareExchange
in interface AmqpAdmin
exchange
- the exchange to declare.@ManagedOperation public boolean deleteExchange(String exchangeName)
AmqpAdmin
deleteExchange
in interface AmqpAdmin
exchangeName
- the name of the exchange@ManagedOperation public String declareQueue(Queue queue)
declareQueue
in interface AmqpAdmin
queue
- the queueignoreDeclarationExceptions
is
true.@ManagedOperation public Queue declareQueue()
declareQueue
in interface AmqpAdmin
ignoreDeclarationExceptions
is true.@ManagedOperation public boolean deleteQueue(String queueName)
AmqpAdmin
deleteQueue
in interface AmqpAdmin
queueName
- the name of the queue@ManagedOperation public void deleteQueue(String queueName, boolean unused, boolean empty)
AmqpAdmin
deleteQueue
in interface AmqpAdmin
queueName
- 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(String queueName, boolean noWait)
AmqpAdmin
purgeQueue
in interface AmqpAdmin
queueName
- the name of the queuenoWait
- true to not await completion of the purge@ManagedOperation public void declareBinding(Binding binding)
AmqpAdmin
declareBinding
in interface AmqpAdmin
binding
- a description of the binding to declare.@ManagedOperation public void removeBinding(Binding binding)
AmqpAdmin
removeBinding
in interface AmqpAdmin
binding
- a description of the binding to remove.public Properties getQueueProperties(String queueName)
QUEUE_NAME
, QUEUE_MESSAGE_COUNT
,
QUEUE_CONSUMER_COUNT
, or null if the queue doesn't exist.getQueueProperties
in interface AmqpAdmin
queueName
- 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 InitializingBean
InitializingBean.afterPropertiesSet()
,
initialize()
public void initialize()