public class BrokerEventListener extends Object implements MessageListener, ApplicationEventPublisherAware, ConnectionListener, SmartLifecycle
BrokerEvents. Such events can then
be consumed using an ApplicationListener or @EventListener method.
An AnonymousQueue will be bound to the amq.rabbitmq.event topic exchange
with the supplied keys.DEFAULT_PHASE| Constructor and Description |
|---|
BrokerEventListener(AbstractMessageListenerContainer container,
String... eventKeys)
Construct an instance using the supplied listener container factory and event keys.
|
BrokerEventListener(ConnectionFactory connectionFactory,
String... eventKeys)
Construct an instance using the supplied connection factory and event keys.
|
| Modifier and Type | Method and Description |
|---|---|
Exception |
getBindingsFailedException()
Return any exception thrown when attempting to bind the queue to the event exchange.
|
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
onCreate(Connection connection)
Called when a new connection is established.
|
void |
onMessage(Message message)
Delivers a single message.
|
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setAutoStartup(boolean autoStartup) |
void |
setPhase(int phase) |
void |
start() |
void |
stop() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontainerAckMode, onMessageBatchonClose, onShutDownstoppublic BrokerEventListener(ConnectionFactory connectionFactory, String... eventKeys)
amq.rabbitmq.event topic exchange. They can therefore match wildcards;
examples are user.#, queue.created. Refer to the plugin documentation for
information about available events. A single-threaded
DirectMessageListenerContainer will be created; its lifecycle will be
controlled by this object's SmartLifecycle methods.connectionFactory - the connection factory.eventKeys - the event keys.public BrokerEventListener(AbstractMessageListenerContainer container, String... eventKeys)
amq.rabbitmq.event topic exchange. They can therefore match wildcards;
examples are user.#, queue.created. Refer to the plugin documentation for
information about available events. The container's lifecycle will be not be
controlled by this object's SmartLifecycle methods. The container should
not be configured with queues or a MessageListener; those properties will
be replaced.container - the listener container.eventKeys - the event keys.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface ApplicationEventPublisherAware@Nullable public Exception getBindingsFailedException()
public int getPhase()
getPhase in interface PhasedgetPhase in interface SmartLifecyclepublic void setPhase(int phase)
public boolean isAutoStartup()
isAutoStartup in interface SmartLifecyclepublic void setAutoStartup(boolean autoStartup)
public void onMessage(Message message)
MessageListeneronMessage in interface MessageListenermessage - the message.public void onCreate(@Nullable Connection connection)
ConnectionListeneronCreate in interface ConnectionListenerconnection - the connection.