Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom message container hook #10050

Open
ansd opened this issue Dec 5, 2023 · 0 comments
Open

Support custom message container hook #10050

ansd opened this issue Dec 5, 2023 · 0 comments

Comments

@ansd
Copy link
Member

ansd commented Dec 5, 2023

Is your feature request related to a problem? Please describe.

It may be desirable to store arbitrary annotations when receiving from a source protocol such that these annotations will be available when consuming.

Describe the solution you'd like

AMQP 0.9.1 channel, MQTT connection, AMQP session, STOMP connection should provide a hook where the message container and the channel state / MQTT processor state / AMQP session state / STOMP processor state are passed in. Then 3rd party implementations can set whatever annotations they want and they will be picked up automatically when consuming from a different protocol:

  • when consuming via AMQP 0.9.1, these annotations will be set as headers
  • when consuming via AMQP, these x-* annotations will be set as message annotations
  • when consuming via MQTT, these annotations could be set as User Property

Describe alternatives you've considered

Somewhat related to #10051

Additional context

This allows for use cases such as https://groups.google.com/g/rabbitmq-users/c/gPJxxG2PGXM/m/EF2BDwpIAQAJ
For MQTT this pluggable message container approach gets called at the same place as

Msg = rabbit_message_interceptor:intercept(Msg0),
, i.e. where we currently call rabbit_message_interceptor. This hook gets as input the message container and the MQTT processor state. The 3rd party implementation could add here the MQTT client ID as annotation. Therefore the MQTT client ID will be available when receiving via AMQP 0.9.1

ansd added a commit to ansd/rabbitmq-server that referenced this issue Dec 6, 2023
as done by mc_amqpl:protocol_state/2 and
mc_amqp:protocol_state/2

We do not include that commit in 3.13 for now as there is no real use
case for it:
Quorum queue client sets x-delivery-count and
stream queue client sets x-stream-offset.
The MQTT plugin does not consume directly from streams, hence there is
no need to set x-stream-offset.
Whether the message is a redelivery from quorum queues is encoded
already in the DUP flag of the MQTT PUBLISH packet.

Also, if source and destination protocols are both MQTT, we must obey:
> The Server MUST send all User Properties unaltered in a PUBLISH packet when forwarding the Application Message to a Client.

We do know if the source protocol was MQTT in mc_mqtt:protoco_state/2 by
checking whether `Topic =/= undefined`.

However, given we don't have a good use case in 3.13, let's not add x-*
annotations as user property.

We park this commit on a branch in case we need it in the future, e.g.
for rabbitmq#10050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant