Skip to content

Commit 2590537

Browse files
committed
Add Message Annotations section
Relates to rabbitmq/rabbitmq-server#13307
1 parent 4c57cda commit 2590537

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

docs/amqp.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ For example, to connect to a virtual host called `tenant-1`, the client sets the
6161

6262
An AMQP 1.0 [address](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-address-string) determines where a message is sent to or consumed from.
6363
What internal object an AMQP address refers to and how an AMQP address is resolved is not defined by the AMQP 1.0 specification.
64-
Different AMQP 1.0 brokers can choose to interprete the provided address differently.
64+
Different AMQP 1.0 brokers can choose to interpret the provided address differently.
6565

6666
RabbitMQ implements the powerful and flexible [AMQ 0.9.1 model](/tutorials/amqp-concepts) comprising [exchanges](/tutorials/amqp-concepts#exchanges), [queues](/tutorials/amqp-concepts#queues), and [bindings](/tutorials/amqp-concepts#bindings).
6767
Therefore, AMQP clients talking to RabbitMQ send messages to exchanges and consume messages from queues.
@@ -219,6 +219,23 @@ As explained previously, RabbitMQ 4.0 allows AMQP clients to create RabbitMQ top
219219
Hence, there is no need for RabbitMQ itself to auto declare a specific queue for a given queue source address format.
220220
In v2, clients should first declare their own queues and bindings, and then attach with source address `/queues/:queue` which causes the client to consume from that queue.
221221

222+
## Message Annotations
223+
224+
When a message is delivered to a consumer, RabbitMQ sets at least the following two [message annotations](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-message-annotations):
225+
* `x-exchange` set to the [exchange](/tutorials/amqp-concepts#exchanges) this message was originally published to.
226+
* `x-routing-key` set to the routing key this message was originally published with.
227+
228+
These message annotations are derived in different ways depending on how the message was originally sent to RabbitMQ. For example, they could be derived from:
229+
* The `address` field of the [target](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-target) an AMQP 1.0 publisher attached to.
230+
* The `to` field of the AMQP 1.0 message [properties](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-properties) section.
231+
* The `exchange` and `routing_key` fields of the AMQP 0.9.1 `basic.publish` frame, if the message was originally published with AMQP 0.9.1.
232+
* The [topic name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107) of an MQTT PUBLISH packet, if the message was originally published with MQTT.
233+
* The name of the [stream](./streams), if the message was originally published with the [RabbitMQ stream protocol](https://github.com/rabbitmq/rabbitmq-server/blob/main/deps/rabbitmq_stream/docs/PROTOCOL.adoc).
234+
235+
However, AMQP 1.0 clients should not publish messages with message annotations `x-exchange` or `x-routing-key` to RabbitMQ.
236+
RabbitMQ will not interpret them.
237+
Instead, if an AMQP 1.0 client wants to re-publish a message to the original exchange with the original routing key, the [address](#addresses) should be set accordingly.
238+
222239
## Outcomes
223240

224241
An [outcome](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-delivery-state) indicates the result of delivery (message)

versioned_docs/version-4.0/amqp.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ For example, to connect to a virtual host called `tenant-1`, the client sets the
6161

6262
An AMQP 1.0 [address](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-address-string) determines where a message is sent to or consumed from.
6363
What internal object an AMQP address refers to and how an AMQP address is resolved is not defined by the AMQP 1.0 specification.
64-
Different AMQP 1.0 brokers can choose to interprete the provided address differently.
64+
Different AMQP 1.0 brokers can choose to interpret the provided address differently.
6565

6666
RabbitMQ implements the powerful and flexible [AMQ 0.9.1 model](/tutorials/amqp-concepts) comprising [exchanges](/tutorials/amqp-concepts#exchanges), [queues](/tutorials/amqp-concepts#queues), and [bindings](/tutorials/amqp-concepts#bindings).
6767
Therefore, AMQP clients talking to RabbitMQ send messages to exchanges and consume messages from queues.
@@ -219,6 +219,23 @@ As explained previously, RabbitMQ 4.0 allows AMQP clients to create RabbitMQ top
219219
Hence, there is no need for RabbitMQ itself to auto declare a specific queue for a given queue source address format.
220220
In v2, clients should first declare their own queues and bindings, and then attach with source address `/queues/:queue` which causes the client to consume from that queue.
221221

222+
## Message Annotations
223+
224+
When a message is delivered to a consumer, RabbitMQ sets at least the following two [message annotations](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-message-annotations):
225+
* `x-exchange` set to the [exchange](/tutorials/amqp-concepts#exchanges) this message was originally published to.
226+
* `x-routing-key` set to the routing key this message was originally published with.
227+
228+
These message annotations are derived in different ways depending on how the message was originally sent to RabbitMQ. For example, they could be derived from:
229+
* The `address` field of the [target](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-target) an AMQP 1.0 publisher attached to.
230+
* The `to` field of the AMQP 1.0 message [properties](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-properties) section.
231+
* The `exchange` and `routing_key` fields of the AMQP 0.9.1 `basic.publish` frame, if the message was originally published with AMQP 0.9.1.
232+
* The [topic name](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901107) of an MQTT PUBLISH packet, if the message was originally published with MQTT.
233+
* The name of the [stream](./streams), if the message was originally published with the [RabbitMQ stream protocol](https://github.com/rabbitmq/rabbitmq-server/blob/main/deps/rabbitmq_stream/docs/PROTOCOL.adoc).
234+
235+
However, AMQP 1.0 clients should not publish messages with message annotations `x-exchange` or `x-routing-key` to RabbitMQ.
236+
RabbitMQ will not interpret them.
237+
Instead, if an AMQP 1.0 client wants to re-publish a message to the original exchange with the original routing key, the [address](#addresses) should be set accordingly.
238+
222239
## Outcomes
223240

224241
An [outcome](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-delivery-state) indicates the result of delivery (message)

0 commit comments

Comments
 (0)