Skip to content

feat: add SessionStateListener callback when a PossDup message is discarded#1259

Merged
chrjohn merged 5 commits into
quickfix-j:masterfrom
mvanhorn:fix/1254-2026-06-12-1151-feat-possdup-discard-callback
Jul 3, 2026
Merged

feat: add SessionStateListener callback when a PossDup message is discarded#1259
chrjohn merged 5 commits into
quickfix-j:masterfrom
mvanhorn:fix/1254-2026-06-12-1151-feat-possdup-discard-callback

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

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
Contributor 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.

Comment thread quickfixj-core/src/main/java/quickfix/Session.java Outdated
@chrjohn chrjohn changed the title feat: add SessionStateListener callback when a PossDup message with too-low MsgSeqNum is discarded feat: add SessionStateListener callback when a PossDup message with too-low MsgSeqNum is discarded Jun 23, 2026
Removed the return value of `doTargetTooLow()` since it is not used anywhere.
@chrjohn chrjohn changed the title feat: add SessionStateListener callback when a PossDup message with too-low MsgSeqNum is discarded feat: add SessionStateListener callback when a PossDup message is discarded Jul 3, 2026
@chrjohn chrjohn added this to the QFJ 3.0.2 milestone Jul 3, 2026
@chrjohn chrjohn merged commit 4f082f1 into quickfix-j:master Jul 3, 2026
12 checks passed
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