rabbitmq / rabbitmq-server

Open source RabbitMQ: core server and tier 1 (built-in) plugins
https://www.rabbitmq.com/
Other
11.86k stars 3.9k forks source link

Use different AMQP address format for v1 and v2 #11604

Closed ansd closed 4 days ago

ansd commented 6 days ago

This PR is a refinement of https://github.com/rabbitmq/rabbitmq-server/pull/10873.

Use different AMQP address format for v1 and v2 to distinguish between v1 and v2 address formats.

Previously, v1 and v2 address formats overlapped and behaved differently for example for:

/queue/:queue
/exchange/:exchange

This PR changes the v2 format to:

/e/:exchange/:routing-key
/e/:exchange
/q/:queue

to distinguish between v1 and v2 addresses.

This allows to call rabbit_deprecated_features:is_permitted(amqp_address_v1) only if we know that the user requests address format v1.

Note that rabbit_deprecated_features:is_permitted/1 should only be called when the old feature is actually used.

Use percent encoding / decoding for address URI format v2. This allows to use any UTF-8 encoded characters including slashes (/) in routing keys, exchange names, and queue names and is more future safe.

Although less user friendly, the new address format is kept short to:

  1. reduce the per message network bandwidth
  2. reduce the per message disk overhead (note that the bare message including the to field must be stored unaltered)
  3. (reduce parsing overhead)

The alternative would have been something like:

/v2/exchange/:exchange/:routing-key
/v2/exchange/:exchange
/v2/queue/:queue

or to set some capabilities or properties when attaching a link denoting that address format v2 is used. Neither of these alternatives is really more user friendly compared to the short version.

Docs PR updating https://www.rabbitmq.com/docs/next/amqp#address will follow soon.