Repository navigation
Conversation
Events published while the AMQP connection is down were discarded. Keep them in a bounded in-memory FIFO buffer and send them in order once the connection is back. - events are buffered only after the broker was reachable once - buffer is capped (bufferSize, default 1000, oldest dropped first) and entries expire (bufferExpiry, default 300000 ms) - publish() no longer connects on the calling thread while the broker is down - ReconnectionTask runs for the lifetime of the bus, so connections closed by the bus itself are re-established as well This change, including the unit test, was generated with an AI assistant (Claude Code). Fixes: apache#14676 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- keep the buffer flush inside the try block, so an unexpected exception cannot end the only reconnect thread - check for an existing connection and connect under the same lock as getConnection(), so a connection created by publish() is not replaced and leaked Generated with an AI assistant (Claude Code). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
Generated with an AI assistant (Claude Code). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR makes the RabbitMQ event bus keep events that are published while the
AMQP broker is unreachable and send them, in the order they were published, once
the connection is back. Until now such events were discarded.
Behaviour:
body, time of buffering).
that,
publish()fails as it does today.bufferSizeevents (default 1000, the oldest isdropped when full) and each event is dropped
bufferExpirymilliseconds(default 300000) after it was buffered.
bufferSize0 disables buffering andrestores the previous behaviour.
appended to the buffer, so they never overtake older ones.
publish()returnsnormally for a buffered event and no longer connects on the calling thread
while the broker is down (the connection timeout of amqp-client 5.17.0 is
60 s).
ReconnectionTasknow runs for the lifetime of the event bus instead of beingstarted by
DisconnectHandler. EveryretryIntervalit drops expired events,reconnects if there is no connection and sends the buffered events. This also
re-establishes connections closed by the bus itself (
AlreadyClosedExceptionin
publish(), blocked connection), which previously started no reconnect.stop()shuts the executor down so the task ends with the bus.Both limits are optional properties of the existing bean, next to the other AMQP
settings:
Known limits, by design:
connection breaks can still be lost unnoticed.
after the reconnect (at-least-once for buffered events).
No new dependencies; the change is confined to
RabbitMQEventBus.Fixes: #14676
AI disclosure: The code, the unit test and this description were generated with an AI assistant. The design and its constraints were set by the submitter and the generated code had been reviewed by the submitter. If the project does not accept AI-generated contributions, please say so and treat this as a proposal for discussion.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
New unit test
RabbitMQEventBusTest(mocked AMQP connection and channel):publish()still fails when the broker was never reachable;an event published while the buffer is not empty does not overtake them;
IOExceptionis buffered and re-sent;The plugin builds and
RabbitMQEventBusTestpasses on main and on the 4.22 branch (mvn -pl plugins/event-bus/rabbitmq -am test -Dtest=RabbitMQEventBusTest).Not yet tested against a real RabbitMQ broker.
How did you try to break this feature and the system with this change?
The unit tests cover a full buffer, expired events, a failing send and a
connection that returns while events are still buffered.