Event Exchange Plugin
Overview
Client connection, channels, queues, consumers, and other parts of the
system naturally generate events. For example, when a connection is
accepted, authenticated and access to the target virtual host is
authorised, it will emit an event of type connection_created. When a
connection is closed or fails for any reason, a connection_closed
event is emitted.
Monitoring and auditing services can be interested in observing those events. RabbitMQ has a minimalistic mechanism for event notifications that can be exposed to RabbitMQ clients with a plugin.
Consuming Internal Events with rabbitmq-event-exchange Plugin
rabbitmq-event-exchange is a plugin that consumes internal events and re-publishes them to a topic exchange, thus exposing the events to clients (applications).
To consume the events, an application needs to declare a queue, bind it to a special system exchange and consume messages.
It declares a topic exchange called amq.rabbitmq.event in the default
virtual host. All events are published to this exchange with routing
keys like 'exchange.created', 'binding.deleted' etc, so you can
subscribe to only the events you're interested in.
The exchange behaves similarly to amq.rabbitmq.log: everything gets
published there; if you don't trust a user with the information that
gets published, don't allow them access.
The plugin requires no configuration, just activate it:
rabbitmq-plugins enable rabbitmq_event_exchange
Each event has various properties associated with it. These are translated into AMQP 0-9-1 data encoding and inserted in the message headers. The message body is always blank.
Events
RabbitMQ and related plugins produce events with the following routing keys:
RabbitMQ Broker
Queue, Exchange and Binding events:
queue.createdqueue.deletedexchange.createdexchange.deletedbinding.createdbinding.deleted
Connection and Channel events:
connection.createdconnection.closedchannel.createdchannel.closed
Consumer events:
consumer.createdconsumer.deleted
Policy and Parameter events:
policy.setpolicy.clearedparameter.setparameter.cleared
Virtual host events:
vhost.createdvhost.deleted
User related events:
user.authentication.successuser.authentication.failureuser.createduser.deleteduser.password.changeduser.password.cleareduser.tags.set
Permission events:
permission.createdpermission.deleted
Shovel Plugin
Worker events:
shovel.worker.statusshovel.worker.removed
Federation Plugin
Link events:
federation.link.statusfederation.link.removed
Example
There is a usage example using the Java client in the rabbitmq-event-exchange repository.