Skip to content

feat: add SessionStateListener callback when a PossDup message with too-low MsgSeqNum is discarded#1259

Open
mvanhorn wants to merge 3 commits into
quickfix-j:masterfrom
mvanhorn:fix/1254-2026-06-12-1151-feat-possdup-discard-callback
Open

feat: add SessionStateListener callback when a PossDup message with too-low MsgSeqNum is discarded#1259
mvanhorn wants to merge 3 commits into
quickfix-j:masterfrom
mvanhorn:fix/1254-2026-06-12-1151-feat-possdup-discard-callback

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

SessionStateListener gains an observe-only callback, onPossDupMessageDiscarded(SessionID, Message), fired when a PossDupFlag=Y message is discarded by the session layer. The spec-mandated discard behavior (FIX session-layer test case 4.5.1(e)) is completely unchanged; applications that need to see these messages, like the GPW WATS case in #1254, can now observe them without forking the engine.

Why this matters

@chrjohn confirmed in #1254 that the discard is spec-correct and will not change, and proposed exactly this: "some kind of handler or callback that is called on reception of a PossDup message ... I have nothing against putting in callbacks for messages that arrive in the engine anyway." The reporter confirmed a callback covers his use case and is currently running a private fork hack. The new method is a default on SessionStateListener (all existing methods are defaults; onResendRequestSatisfied is precedent for callbacks with context), invoked via the existing stateListener multiplexer at the discard sites in doTargetTooLow() and the expected-seqnum validatePossDup failure branch in verify(). The javadoc states the message was not processed by the application and must not be mutated.

Testing

SessionTest gains cases for the too-low PossDup discard (callback fires, message untouched), the expected-seqnum OrigSendingTime failure (callback fires after the session Reject, target sequence advanced accordingly), and the no-callback path for normal messages. No Java runtime was available in the implementation environment, so CI is the verification run for the suite.

Fixes #1254

@chrjohn

chrjohn commented Jun 12, 2026

Copy link
Copy Markdown
Member

@mvanhorn thanks for the PR, will have a look...
ATM unit test is failing.
Invalid use of argument matchers!

Wrap the raw session.getSessionID() argument in eq() so it is not mixed
with the messageCaptor.capture() matcher in the same verify() call, which
raised InvalidUseOfMatchersException. Add the ArgumentMatchers.eq import.
@mvanhorn

Copy link
Copy Markdown
Author

Thanks @chrjohn. Fixed in edd22ad - the failing test mixed a raw session.getSessionID() with messageCaptor.capture() in the same verify(...), which Mockito rejects (all args must be matchers once one is). Wrapped the session ID in eq(...) and added the import.

Verified locally on JDK 21: the four onPossDupMessageDiscarded tests in SessionTest now pass (Tests run: 4, Failures: 0, Errors: 0). CI should go green on the next run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discarding PossDup messages with too low seqnum

2 participants