rabbitmq-server icon indicating copy to clipboard operation
rabbitmq-server copied to clipboard

Support custom message container hook

Open ansd opened this issue 6 months ago • 0 comments

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 https://github.com/rabbitmq/rabbitmq-server/issues/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 https://github.com/rabbitmq/rabbitmq-server/blob/f54f880ca9d289ee633b0e0f3c921199854a8841/deps/rabbitmq_mqtt/src/rabbit_mqtt_processor.erl#L1555 , 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 avatar Dec 05 '23 09:12 ansd