Repository navigation
[Fix] DLQ Messages will lose system properties when sent from reconsumeLater() - #1392
Merged
RobertIndie merged 1 commit intoAug 7, 2025
Merged
Conversation
geniusjoe
force-pushed
the
bugfix/dlq-RealTopic-property
branch
from
July 15, 2025 08:10
184037c to
8a81866
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where DLQ (Dead Letter Queue) messages lose system properties when sent from reconsumeLater() method. The fix ensures that system properties like REAL_TOPIC and ORIGIN_MESSAGE_ID are consistently preserved for both Nack() and ReconsumeLater() code paths, while also preserving additional message metadata.
Key changes:
- Moved system property addition from DLQ router to the source methods (
dispatcher()andReconsumeLaterWithCustomProperties()) - Added preservation of message metadata (Key, OrderingKey, EventTime) in both DLQ and RLQ flows
- Updated tests to verify the preservation of all message properties and metadata
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsar/message.go | Fixed typo in comment ("be be" → "be") |
| pulsar/dlq_router.go | Removed system property addition logic and simplified message creation |
| pulsar/consumer_partition.go | Added system property creation and message metadata preservation for Nack flow |
| pulsar/consumer_impl.go | Enhanced ReconsumeLater to preserve all message metadata and system properties |
| pulsar/consumer_test.go | Added comprehensive tests for message property and metadata preservation |
RobertIndie
reviewed
Jul 28, 2025
RobertIndie
left a comment
Member
There was a problem hiding this comment.
Could you also take a look at the copilot comments?
geniusjoe
force-pushed
the
bugfix/dlq-RealTopic-property
branch
from
August 6, 2025 14:31
8a81866 to
6c6775e
Compare
geniusjoe
force-pushed
the
bugfix/dlq-RealTopic-property
branch
from
August 6, 2025 14:50
6c6775e to
9729b65
Compare
RobertIndie
approved these changes
Aug 7, 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 #1388
Master Issue: #907, apache/pulsar#23182
Motivation
Since pulsar sdk does not support
AckTimeout()method, we can only useNack()orReconsumeLater()to trigger dlq policy and send messages to dlq. We can find system properties(e.g.REAL_TOPICandORIGIN_MESSAGE_ID) in these dlq messages.Refer to issue #1388, before pr #907
dlq_router#run()will directly copy properties to create a new dlq message when receiving a message fromdlq.Chan(). But we only define message properties in ReconsumeLater'sReconsumeLaterWithCustomProperties()and not in Nack'sdispatcher()before send to thisdlq.Chan(), which lead to only dlq messages created byReconsumeLater()can have these properties.The above pr replaced this behavior with just adding system properties as soon as creating dlq messages in
dlq_router#run(), which usemessage.topicasREAL_TOPICproperty value. But messages sent fromReconsumeLater() ReconsumeLaterWithCustomProperties()do not contain relatedmessage.topicfields, in case it will override definedREAL_TOPICto empty string.Modifications
REAL_TOPIC,ORIGIN_MESSAGE_IDY_TIME,ORIGIN_MESSAGE_IDsystem properties both in ReconsumeLater'sReconsumeLaterWithCustomProperties()and Nack'sdispatcher()functions.Key,OrderingKey,EventTimemessage fields both inReconsumeLater() ReconsumeLaterWithCustomProperties()anddlq_router run()functions to keep consistent with Java realization, so that dlq messages can preserve source message info.dlq_router#run().Verifying this change
This change updated tests and can be verified as follows:
DLQWithProducerOptions
TestRLQ
Does this pull request potentially affect one of the following parts:
Documentation