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 exchange federation with MQTT 5.0 subscribers #13115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ansd
Copy link
Member

@ansd ansd commented Jan 21, 2025

What?

This commit fixes #13040.

Prior to this commit, exchange federation crashed if the MQTT topic exchange
(amq.topic by default) got federated and MQTT 5.0 clients subscribed on the
downstream. That's because the federation plugin sends bindings from downstream
to upstream via AMQP 0.9.1. However, binding arguments containing Erlang record
mqtt_subscription_opts (henceforth binding args v1) cannot be encoded in AMQP 0.9.1.

Why?

Federating the MQTT topic exchange could be useful for warm standby use cases.

How?

This commit makes binding arguments a valid AMQP 0.9.1 table (henceforth
binding args v2).

Binding args v2 can only be used if all nodes support it. Hence binding
args v2 comes with feature flag rabbitmq_4.1.0. Note that the AMQP
over WebSocket
PR already
introduces this same feature flag. Although the feature flag subsystem
supports plugins to define their own feature flags, and the MQTT plugin
defined its own feature flags in the past, reusing feature flag
rabbitmq_4.1.0 is simpler.

This commit also avoids database migrations for both Mnesia and Khepri
if feature flag rabbitmq_4.1.0 gets enabled. Instead, it's simpler to
migrate binding args v1 to binding args v2 at MQTT connection establishment
time if the feature flag is enabled. (If the feature flag is disabled at
connection etablishment time, but gets enabled during the connection
lifetime, the connection keeps using bindings args v1.)

This commit adds two new suites:

  1. federation_SUITE which tests that federating the MQTT topic
    exchange works, and
  2. feature_flag_SUITE which tests the binding args migration from v1 to v2

@ansd ansd added this to the 4.1.0 milestone Jan 21, 2025
@mergify mergify bot added the make label Jan 21, 2025
 ## What?
This commit fixes #13040.

Prior to this commit, exchange federation crashed if the MQTT topic exchange
(`amq.topic` by default) got federated and MQTT 5.0 clients subscribed on the
downstream. That's because the federation plugin sends bindings from downstream
to upstream via AMQP 0.9.1. However, binding arguments containing Erlang record
`mqtt_subscription_opts` (henceforth binding args v1) cannot be encoded in AMQP 0.9.1.

 ## Why?
Federating the MQTT topic exchange could be useful for warm standby use cases.

 ## How?
This commit makes binding arguments a valid AMQP 0.9.1 table (henceforth
binding args v2).

Binding args v2 can only be used if all nodes support it. Hence binding
args v2 comes with feature flag `rabbitmq_4.1.0`. Note that the AMQP
over WebSocket
[PR](#13071) already
introduces this same feature flag. Although the feature flag subsystem
supports plugins to define their own feature flags, and the MQTT plugin
defined its own feature flags in the past, reusing feature flag
`rabbitmq_4.1.0` is simpler.

This commit also avoids database migrations for both Mnesia and Khepri
if feature flag `rabbitmq_4.1.0` gets enabled. Instead, it's simpler to
migrate binding args v1 to binding args v2 at MQTT connection establishment
time if the feature flag is enabled. (If the feature flag is disabled at
connection etablishment time, but gets enabled during the connection
lifetime, the connection keeps using bindings args v1.)

This commit adds two new suites:
1. `federation_SUITE` which tests that federating the MQTT topic
   exchange works, and
2. `feature_flag_SUITE` which tests the binding args migration from v1 to v2.
@ansd ansd marked this pull request as ready for review January 22, 2025 10:25
@ansd
Copy link
Member Author

ansd commented Jan 22, 2025

The two CI checks fail for the same reason as in #13071 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Federated MQTT topic exchange with MQTT 5.0 subscribers
2 participants