Skip to content

Commit d73fa74

Browse files
Merge pull request #2129 from rabbitmq/amqp-event-exchange
Update Event Exchange Plugin docs
2 parents 0da41f3 + 971deea commit d73fa74

File tree

2 files changed

+52
-89
lines changed

2 files changed

+52
-89
lines changed

docs/event-exchange.md

Lines changed: 46 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -22,116 +22,77 @@ limitations under the License.
2222

2323
## Overview
2424

25-
Client connection, channels, queues, consumers, and other parts of the
26-
system [naturally generate events](./logging#internal-events). For example, when a connection is
27-
accepted, authenticated and access to the target virtual host is
28-
authorised, it will emit an event of type `connection_created`. When a
29-
connection is closed or fails for any reason, a `connection_closed`
30-
event is emitted.
31-
32-
[Monitoring](./monitoring) and auditing services can be interested in observing those
33-
events. RabbitMQ has a minimalistic mechanism for event notifications
34-
that can be exposed to RabbitMQ clients with a plugin.
35-
36-
37-
## Consuming Internal Events with rabbitmq-event-exchange Plugin
38-
39-
[rabbitmq-event-exchange](https://github.com/rabbitmq/rabbitmq-event-exchange)
40-
is a plugin that consumes internal events and re-publishes them to a
41-
topic exchange, thus exposing the events to clients (applications).
42-
43-
To consume the events, an application needs to declare a queue, bind
44-
it to a special system exchange and consume messages.
25+
Client connections, queues, consumers, and other parts of the system generate [events](./logging#internal-events).
26+
For example, when a connection is created, a `connection.created` event is emitted.
27+
When a connection is closed or fails, a `connection.closed` event is emitted.
4528

46-
It declares a topic exchange called `amq.rabbitmq.event` in the default
47-
virtual host. All events are published to this exchange with routing
48-
keys like 'exchange.created', 'binding.deleted' etc, so you can
49-
subscribe to only the events you're interested in.
50-
51-
The exchange behaves similarly to `amq.rabbitmq.log`: everything gets
52-
published there; if you don't trust a user with the information that
53-
gets published, don't allow them access.
29+
[Monitoring](./monitoring) and auditing services can be interested in observing these
30+
events. RabbitMQ has a minimalistic mechanism for event notifications
31+
that can be exposed to RabbitMQ clients with the `rabbitmq_event_exchange` plugin.
5432

5533
The plugin requires no configuration, just activate it:
5634

5735
```bash
5836
rabbitmq-plugins enable rabbitmq_event_exchange
5937
```
6038

61-
Each event has various properties associated with it. These are
62-
translated into AMQP 0-9-1 data encoding and inserted in the message headers. The
63-
**message body is always blank**.
64-
65-
66-
## Events
39+
## Consuming Internal Events
6740

68-
RabbitMQ and related plugins produce events with the following routing keys:
41+
[rabbitmq_event_exchange](https://github.com/rabbitmq/rabbitmq-server/tree/main/deps/rabbitmq_event_exchange)
42+
is a plugin that consumes RabbitMQ internal events and re-publishes them to a
43+
[topic exchange](/tutorials/amqp-concepts#exchange-topic) called `amq.rabbitmq.event`, thus exposing these events to clients applications.
44+
To consume the events, an application needs to declare a queue and bind it to the `amq.rabbitmq.event` exchange.
6945

70-
### RabbitMQ Broker
46+
By default, the plugin declares the topic exchange `amq.rabbitmq.event` in the default virtual host (`/`).
47+
All events are published to this exchange with routing keys (topics) such as `exchange.created`, `binding.deleted`, etc.
48+
Applications can therefore consume only the relevant events.
49+
For example, to subscribe to all user events (such as `user.created`, `user.authentication.failure`, etc.) create a binding with routing (binding) key `user.#`.
7150

72-
Queue, Exchange and Binding events:
51+
The exchange behaves similarly to `amq.rabbitmq.log`: everything gets published there.
52+
If application's user cannot be trusted with the events that get published, don't [allow](./access-control) them `read` access to the `amq.rabbitmq.event` exchange.
7353

74-
- `queue.created`
75-
- `queue.deleted`
76-
- `exchange.created`
77-
- `exchange.deleted`
78-
- `binding.created`
79-
- `binding.deleted`
54+
::: important
8055

81-
Connection and Channel events:
56+
All messages published by the internal event mechanism will always have a blank body.
57+
Relevant event attributes are passed in message metadata.
8258

83-
- `connection.created`
84-
- `connection.closed`
85-
- `channel.created`
86-
- `channel.closed`
59+
:::
8760

88-
Consumer events:
61+
Each event has various event properties associated with it.
62+
By default, the plugin internally publishes AMQP 0.9.1 messages with event properties translated to AMQP 0.9.1 message headers.
63+
The plugin can optionally be configured to internally publish AMQP 1.0 messages with event properties translated to AMQP 1.0 [message-annotations](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-message-annotations)
64+
by setting the following in [rabbitmq.conf](configure#config-file):
8965

90-
- `consumer.created`
91-
- `consumer.deleted`
92-
93-
Policy and Parameter events:
94-
95-
- `policy.set`
96-
- `policy.cleared`
97-
- `parameter.set`
98-
- `parameter.cleared`
99-
100-
Virtual host events:
101-
102-
- `vhost.created`
103-
- `vhost.deleted`
104-
105-
User related events:
66+
```
67+
event_exchange.protocol = amqp_1_0
68+
```
10669

107-
- `user.authentication.success`
108-
- `user.authentication.failure`
109-
- `user.created`
110-
- `user.deleted`
111-
- `user.password.changed`
112-
- `user.password.cleared`
113-
- `user.tags.set`
70+
All messages published by the internal event mechanism will always have a blank body.
71+
Relevant event attributes are passed in message metadata.
11472

115-
Permission events:
73+
Because the plugin sets event properties as AMQP 0.9.1 headers or AMQP 1.0 message-annotations, client applications can optionally subscribe to only specific event properties (for example all events emitted for a specific user). This can be achieved by binding a queue to a [headers exchange](/tutorials/amqp-concepts#exchange-headers), and the headers exchange to the `amq.rabbitmq.event` topic exchange.
11674

117-
- `permission.created`
118-
- `permission.deleted`
75+
### Events
11976

120-
### Shovel Plugin
77+
Events including their routing keys (topics) that this plugin publishes are documented [here](./logging#internal-events).
12178

122-
Worker events:
79+
### Example
12380

124-
- `shovel.worker.status`
125-
- `shovel.worker.removed`
81+
There's an [example internal event consumer in Java](https://github.com/rabbitmq/rabbitmq-server/tree/main/deps/rabbitmq_event_exchange/examples/java).
12682

127-
### Federation Plugin
12883

129-
Link events:
84+
## Plugin Configuration
13085

131-
- `federation.link.status`
132-
- `federation.link.removed`
86+
By default, the `rabbitmq_event_exchange` plugin uses the following configuration:
13387

88+
``` ini
89+
event_exchange.vhost = /
90+
event_exchange.protocol = amqp_0_9_1
91+
```
13492

135-
## Example
93+
To switch the plugin to publish events in the AMQP 1.0 format, use
13694

137-
There is a usage example using the Java client [in the rabbitmq-event-exchange repository](https://github.com/rabbitmq/rabbitmq-event-exchange/tree/master/examples/java).
95+
``` ini
96+
event_exchange.vhost = /
97+
event_exchange.protocol = amqp_1_0
98+
```

docs/logging.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ The events can also be exposed to applications for [consumption](./consumers)
937937
with [a plugin](./event-exchange).
938938

939939
Events are published as messages with blank bodies. All event metadata is stored in
940-
message metadata (properties, headers).
940+
message annotations (properties, headers).
941941

942942
Below is a list of published events.
943943

@@ -952,7 +952,7 @@ Below is a list of published events.
952952
* `binding.created`
953953
* `binding.deleted`
954954

955-
[Connection](./connections) and [Channel](./channels) events:
955+
[Connection](./connections) and AMQP 0.9.1 [Channel](./channels) events:
956956

957957
* `connection.created`
958958
* `connection.closed`
@@ -968,6 +968,8 @@ Below is a list of published events.
968968

969969
* `policy.set`
970970
* `policy.cleared`
971+
* `queue.policy.updated`
972+
* `queue.policy.cleared`
971973
* `parameter.set`
972974
* `parameter.cleared`
973975

@@ -980,10 +982,10 @@ Below is a list of published events.
980982

981983
User management events:
982984

983-
* `user.authentication.success`
984-
* `user.authentication.failure`
985985
* `user.created`
986986
* `user.deleted`
987+
* `user.authentication.success`
988+
* `user.authentication.failure`
987989
* `user.password.changed`
988990
* `user.password.cleared`
989991
* `user.tags.set`

0 commit comments

Comments
 (0)