KevinLiLu commented on code in PR #21798:
URL: https://github.com/apache/pulsar/pull/21798#discussion_r1435896433
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java:
##########
@@ -263,6 +263,29 @@ public boolean checkAndStartPublish(long producerId, long
sequenceId, ByteBuf he
}
}
+ if (topic.isPersistent()) {
+ PersistentTopic pTopic = (PersistentTopic) topic;
+ if (pTopic.isDelayedDeliveryEnabled()) {
+ long maxDeliveryDelayInMs =
pTopic.getDelayedDeliveryMaxDelayInMillis();
+ if (maxDeliveryDelayInMs > 0) {
+ headersAndPayload.markReaderIndex();
+ MessageMetadata msgMetadata =
Commands.parseMessageMetadata(headersAndPayload);
+ headersAndPayload.resetReaderIndex();
Review Comment:
An alternative which completely avoids impacting the publish flow is to
perform this check when dispatching the message to the consumers in
`PersistentDispatcherMultipleConsumers`:
https://github.com/apache/pulsar/blob/32f3577a735581096d85aa961d7df45b9ae9b6f9/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java#L1048-L1062
If the broker sees a `deliverAtTime` which exceeds the configured max, it
can override the `deliverAtTime` to be the max possible value based on the
config (so that it equals `publishTime + maxDeliveryDelayInMs`)
The disadvantage with this approach is the producer will not get any
indication that their proposed `deliverAtTime` was changed which can cause some
confusion/churn. But maybe this is acceptable because the
`delayedDeliveryEnabled` config works the same way (if delayed delivery is
disabled, message is just delivered immediately and producer never receives an
error).
This approach does have some major advantages:
1. Publish performance is not impacted
2. Consumer using retry/dlq feature will never get stuck (see issue I
mentioned
[here](https://github.com/apache/pulsar/blob/master/pip/pip-315.md#consumer-impact))
@lhotari what are your thoughts on this proposed change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]