Jason918 commented on code in PR #15963:
URL: https://github.com/apache/pulsar/pull/15963#discussion_r895289610
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java:
##########
@@ -215,13 +219,19 @@ protected void sendMessagesToConsumers(ReadType readType,
List<Entry> entries) {
final Map<Consumer, Set<Integer>> consumerStickyKeyHashesMap = new
HashMap<>();
for (Entry entry : entries) {
- int stickyKeyHash = getStickyKeyHash(entry);
+ final int stickyKeyHash = getStickyKeyHash(entry);
+ final long ledgerId = entry.getLedgerId();
+ final long entryId = entry.getEntryId();
Consumer c = selector.select(stickyKeyHash);
if (c != null) {
groupedEntries.computeIfAbsent(c, k -> new
ArrayList<>()).add(entry);
consumerStickyKeyHashesMap.computeIfAbsent(c, k -> new
HashSet<>()).add(stickyKeyHash);
+ unMatchConsumerBackoff.reset();
} else {
- addMessageToReplay(entry.getLedgerId(), entry.getEntryId(),
stickyKeyHash);
+ topic.getBrokerService().executor().schedule(() -> {
+ addMessageToReplay(ledgerId, entryId, stickyKeyHash);
+ }, unMatchConsumerBackoff.next(), TimeUnit.MILLISECONDS);
Review Comment:
`unMatchConsumerBackoff.next()` seems odd here.
Consider the case when all entry in `entries` have the same `stickyKeyHash`,
the delay time increases in the same batch entries.
--
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]