-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support publishing AMQP 1.0 to Event Exchange
## What? Prior to this commit, the `rabbitmq_event_exchange` internally published always AMQP 0.9.1 messages to the `amq.rabbitmq.event` topic exchange. This commit allows users to configure the plugin to publish AMQP 1.0 messages instead. ## Why? Prior to this commit, when an AMQP 1.0 client consumed events, event properties that are lists were omitted, for example property `client_properties` of event `connection.created` or property `arguments` of event `queue.created` because of the following sequence: 1. The event exchange plugins listens for all kind of internal events. 2. The event exchange plugin re-publishes all events as AMQP 0.9.1 message to the event exchange. 3. Later, when an AMQP 1.0 client consumes this message, the broker must translate the message from AMQP 0.9.1 to AMQP 1.0. 4. This translation follows the rules outlined in https://www.rabbitmq.com/docs/conversions#amqpl-amqp 5. Specifically, in this table the row before the last one describes the rule we're hitting here. It says that if the AMQP 0.9.1 header value is not an `x-` prefixed header and its value is an array or table, then this header is not converted. That's because AMQP 1.0 application-properties must be simple types as mandated in https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-application-properties ## How? The user can configure the plugin as follows to have the plugin internally publish AMQP 1.0 messages: ``` event_exchange.protocol = amqp_1_0 ``` To support complex types such as lists, the plugin sets all event properties as message-annotations. The plugin prefixes all message annotation keys with `x-opt-` to comply with the AMQP 1.0 spec. ## Alternative Design An alternative design would have been to format all event properties e.g. as JSON within the message body. However, this breaks routing on specific event property values via a headers exchange. ## Documentation rabbitmq/rabbitmq-website#2129
- Loading branch information
Showing
10 changed files
with
554 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,154 +1,7 @@ | ||
# RabbitMQ Event Exchange | ||
|
||
## Overview | ||
|
||
This plugin exposes the internal RabbitMQ event mechanism as messages that clients | ||
can consume. It's useful | ||
if you want to keep track of certain events, e.g. when queues, exchanges, bindings, users, | ||
connections, channels are created and deleted. This plugin filters out stats | ||
events, so you are almost certainly going to get better results using | ||
the management plugin for stats. | ||
|
||
## How it Works | ||
|
||
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. | ||
|
||
|
||
## Installation | ||
|
||
This plugin ships with RabbitMQ. Like with all other plugins, it must be | ||
enabled before it can be used: | ||
|
||
```bash | ||
[sudo] rabbitmq-plugins enable rabbitmq_event_exchange | ||
``` | ||
|
||
## Event format | ||
|
||
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 | ||
|
||
So far RabbitMQ and related plugins emit events with the following routing keys: | ||
|
||
### RabbitMQ Broker | ||
|
||
Queue, Exchange and Binding events: | ||
|
||
* `queue.deleted` | ||
* `queue.created` | ||
* `exchange.created` | ||
* `exchange.deleted` | ||
* `binding.created` | ||
* `binding.deleted` | ||
|
||
Connection and Channel events: | ||
|
||
* `connection.created` | ||
* `connection.closed` | ||
* `channel.created` | ||
* `channel.closed` | ||
|
||
Consumer events: | ||
|
||
* `consumer.created` | ||
* `consumer.deleted` | ||
|
||
Policy and Parameter events: | ||
|
||
* `policy.set` | ||
* `policy.cleared` | ||
* `parameter.set` | ||
* `parameter.cleared` | ||
|
||
Virtual host events: | ||
|
||
* `vhost.created` | ||
* `vhost.deleted` | ||
* `vhost.limits.set` | ||
* `vhost.limits.cleared` | ||
|
||
User related events: | ||
|
||
* `user.authentication.success` | ||
* `user.authentication.failure` | ||
* `user.created` | ||
* `user.deleted` | ||
* `user.password.changed` | ||
* `user.password.cleared` | ||
* `user.tags.set` | ||
|
||
Permission events: | ||
|
||
* `permission.created` | ||
* `permission.deleted` | ||
* `topic.permission.created` | ||
* `topic.permission.deleted` | ||
|
||
Alarm events: | ||
|
||
* `alarm.set` | ||
* `alarm.cleared` | ||
|
||
### Shovel Plugin | ||
|
||
Worker events: | ||
|
||
* `shovel.worker.status` | ||
* `shovel.worker.removed` | ||
|
||
### Federation Plugin | ||
|
||
Link events: | ||
|
||
* `federation.link.status` | ||
* `federation.link.removed` | ||
|
||
## Example | ||
|
||
There is a usage example using the Java client in `examples/java`. | ||
|
||
|
||
## Configuration | ||
|
||
* `rabbitmq_event_exchange.vhost`: what vhost should the `amq.rabbitmq.event` exchange be declared in. Default: `rabbit.default_vhost` (`<<"/">>`). | ||
|
||
|
||
## Uninstalling | ||
|
||
If you want to remove the exchange which this plugin creates, first | ||
disable the plugin and restart the broker. Then you can delete the exchange, | ||
e.g. with : | ||
|
||
rabbitmqctl eval 'rabbit_exchange:delete(rabbit_misc:r(<<"/">>, exchange, <<"amq.rabbitmq.event">>), false, <<"username">>).' | ||
|
||
|
||
## Building from Source | ||
|
||
Building is no different from [building other RabbitMQ plugins](https://www.rabbitmq.com/plugin-development.html). | ||
|
||
TL;DR: | ||
|
||
git clone https://github.com.com/rabbitmq/rabbitmq-public-umbrella.git umbrella | ||
cd umbrella | ||
make co | ||
make up BRANCH=stable | ||
cd deps | ||
git clone https://github.com/rabbitmq/rabbitmq-event-exchange.git rabbitmq_event_exchange | ||
cd rabbitmq_event_exchange | ||
make dist | ||
|
||
See the [website](https://www.rabbitmq.com/docs/event-exchange) for documentation. | ||
|
||
## License | ||
|
||
Released under the Mozilla Public License 2.0, | ||
the same as RabbitMQ. | ||
Released under the Mozilla Public License 2.0, the same as RabbitMQ. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.