Repository navigation
fix: handle reconnection logic for zero queue consumer - #1404
Merged
Merged
Conversation
- Add enableZeroQueueConsumer flag to ConsumerOptions- Implement reconnection logic for zero queue consumer - Update availablePermits on reconnect for zero queue consumer - Add test case for zero queue consumer reconnection
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes reconnection issues for ZeroQueueConsumer when the broker restarts or unloads topics. The fix ensures that zero queue consumers can continue consuming messages after broker interruptions.
- Increases
availablePermitson reconnection for zero queue consumers to restore message flow - Suppresses error logging for initial permits when using zero queue consumers
- Adds comprehensive test coverage for zero queue consumer reconnection scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pulsar/consumer_zero_queue_test.go | Adds integration test that simulates broker restart with Docker containers |
| pulsar/consumer_partition.go | Implements reconnection logic and suppresses error logging for zero queue consumers |
| pulsar/consumer_impl.go | Passes enableZeroQueueConsumer flag to partition consumer options |
Comments suppressed due to low confidence (4)
pulsar/consumer_zero_queue_test.go:220
- The test has a fixed 5-second sleep after receiving each message, making it take 50+ seconds to complete. This creates an unnecessarily slow test. Consider reducing the sleep time or removing it entirely if it's not essential for the test logic.
time.Sleep(5 * time.Second)
pulsar/consumer_zero_queue_test.go:195
- The variable name 'time' shadows the imported 'time' package, which could cause confusion. Consider renaming it to 'timeout' or 'stopTimeout'.
time := 5 * time.Second
pulsar/consumer_zero_queue_test.go:206
- The test uses log.Fatal(err) which will terminate the entire test suite if a message receive fails. This prevents proper cleanup of the Docker container. Consider using assert.NoError(t, err) or require.NoError(t, err) instead to ensure proper test failure handling.
if err != nil {
pulsar/consumer_zero_queue_test.go:141
- Setting Reuse: true for the test container could cause issues if multiple tests run concurrently or if the container state persists between test runs. Consider setting this to false for more predictable test behavior.
Reuse: true,
- Replace broker restart simulation with topic unloading - Add pulsar admin client to perform topic operations - Synchronize message reception with topic unloading event - Remove unnecessary sleep for more deterministic test behavior
BewareMyPower
approved these changes
Aug 29, 2025
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.
Fixes #1330 #398
Motivation
ZeroQueueConsumercannot consume messages when the broker restarts or unload topic.Modifications
availablePermitson reconnect forZeroQueueConsumerZeroQueueConsumer.Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation