Consumer received duplicated deplayed messages upon restart
Fix when send a delayed message ,there is a case when a consumer restarts and pull duplicate messages.
@@ -1116,7 +1116,14 @@ public class ManagedCursorImpl implements ManagedCursor {
};
positions.stream().filter(position -> !alreadyAcknowledgedPositions.contains(position))
- .forEach(p -> ledger.asyncReadEntry((PositionImpl) p, cb, ctx));
+ .forEach(p ->{
+ if (((PositionImpl) p).compareTo(this.readPosition) == 0) {
+ this.setReadPosition(this.readPosition.getNext());
+ log.warn("[{}][{}] replayPosition{} equals readPosition{}," + " need set next readPositio",
+ ledger.getName(), name, (PositionImpl) p, this.readPosition);
+ }
+ ledger.asyncReadEntry((PositionImpl) p, cb, ctx);
+ });
return alreadyAcknowledgedPositions;
}
