-
Notifications
You must be signed in to change notification settings - Fork 198
RabbitMQ: shared connections with context safety and config mismatch guard #3266
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
base: main
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| public static String computeConnectionFingerprint(RabbitMQOptions options) { | ||
| StringBuilder raw = new StringBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, we can use the options.toJson().encode() and create the sha of that representation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using options.toJson().encode() may introduce some risks, since it includes fields that are not relevant to the connection’s identity and may not preserve the original order. The current fingerprint normalizes the data, avoiding volatility. I may be mistaken. What do you think?
We could use .toJson() and, from it, only remove the fields and normalize the lists. That could make the code more concise.
| } | ||
| } | ||
|
|
||
| public void ensureContext(Context context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't the shared client switch context with each channel with shared connection ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. In a shared connection, the ClientHolder keeps a single connection context set once via ensureContext (compare-and-set) and it does not switch per channel. Each IncomingRabbitMQChannel creates its own context for message processing and passes it to IncomingRabbitMQMessage, so ack/nack runs on the channel context, not a per-channel connection context.
Summary
Configuration
Example:
If two channels share the same name but have different connection settings, startup fails with:
Shared connection '<name>' has mismatched configuration...Breaking changes / Documentation
./mvnw -pl smallrye-reactive-messaging-rabbitmq -DskipITs testSimple flowchart:
Fixes #3189