Skip to content

Honour PMode ReceptionAwareness.DuplicateDetection on incoming messages - #402

Merged
phax merged 1 commit into
phax:masterfrom
Dinpo:fix/duplicate-detection-honours-pmode
Sep 30, 2026
Merged

phax merged 1 commit into
phax:masterfrom
Dinpo:fix/duplicate-detection-honours-pmode

Conversation

@Dinpo

@Dinpo Dinpo commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Problem

PModeReceptionAwareness has a DuplicateDetection flag (isDuplicateDetection(), default true), and it is serialised with the PMode, but nothing consults it when a message is received. AS4RequestHandler always calls MetaAS4Manager.getIncomingDuplicateMgr().registerAndCheck(...), so a PMode with duplicate detection explicitly set to false still gets EBMS:4001 DuplicateDetected for a repeated MessageId.

We hit this with a receiver that does its own, storage-backed idempotency: when our processor SPI failed to persist a message (and returned an ebMS error, so no receipt was sent), the sender's resend of the same MessageId was rejected as a duplicate by phase4, although the PMode said not to detect duplicates. Our workaround is a custom IAS4ManagerFactory whose duplicate manager never reports duplicates.

Change

AS4RequestHandler skips the duplicate check only when the resolved PMode has a ReceptionAwareness whose isDuplicateDetection() is false. With no PMode, no ReceptionAwareness, or an undefined value, behaviour is exactly as before (duplicates are detected).

Tests

  • UserMessageDuplicateTest#testDuplicateDetectionDisabledInPMode (new): with duplicate detection disabled in the receiving PModes, the same message is accepted twice. Without the change it fails with EBMS:4001.
  • The three existing duplicate tests are unchanged and still pass.
  • mvn -pl phase4-lib,phase4-test test: 161 + 206 tests, 0 failures (9 existing @Ignore).

Related observation, not changed here: the MessageId is registered as "seen" before the processor SPIs run and stays registered when they fail, so a sender that retries after an EBMS:0004-style processing error gets EBMS:4001 instead of a second attempt. If you think that is worth addressing (e.g. unregistering on SPI failure), I am happy to open a separate issue or PR.

🤖 Generated with Claude Code

The flag was stored with the PMode but never consulted: AS4RequestHandler
always ran the duplicate check. The check is now skipped when the resolved
PMode explicitly disables duplicate detection; the default is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@phax

phax commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks, makes sense. Will be part of 4.8.0 release

@phax
phax merged commit d020a69 into phax:master Sep 30, 2026
3 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.

2 participants