diff --git a/waltz-server/src/main/java/com/wepay/waltz/server/internal/FeedContext.java b/waltz-server/src/main/java/com/wepay/waltz/server/internal/FeedContext.java index 9a1c3b9..021c689 100644 --- a/waltz-server/src/main/java/com/wepay/waltz/server/internal/FeedContext.java +++ b/waltz-server/src/main/java/com/wepay/waltz/server/internal/FeedContext.java @@ -12,7 +12,15 @@ public class FeedContext { public static final Comparator HIGH_WATER_MARK_COMPARATOR = - (o1, o2) -> o1.highWaterMark < o2.highWaterMark ? -1 : o1.highWaterMark > o2.highWaterMark ? 1 : 0; + (o1, o2) -> { + int hwmCompare = Long.compare(o1.highWaterMark, o2.highWaterMark); + + if (hwmCompare == 0) { + return Integer.compare(o1.reqId.seqNum(), o2.reqId.seqNum()); + } + + return hwmCompare; + }; public final ReqId reqId; public final PartitionClient sender;