Skip to content

QUEUE-144: Support context listeners in marshallable outputs - #1273

Closed
peter-lawrey wants to merge 1 commit into
feature/QUEUE-144-wire-context-listener-lifecyclefrom
feature/QUEUE-144-wire-marshallable-out-listeners
Closed

peter-lawrey wants to merge 1 commit into
feature/QUEUE-144-wire-context-listener-lifecyclefrom
feature/QUEUE-144-wire-marshallable-out-listeners

Conversation

@peter-lawrey

@peter-lawrey peter-lawrey commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Enables contextListener(...) for append-mode file, string-consumer, and HTTP MarshallableOut implementations.
  • Treats append files and string consumers as one logical output context across buffer clears.
  • Treats each top-level HTTP document as a new output context, so every independent POST contains the context needed to interpret it.
  • Rejects context listeners for overwrite-mode files because each document replaces the file and would discard context written by an earlier document.
  • Tests complete serialised output with representative context and event DTOs.

Purpose

#1272 implements once-per-output-context listener notification on writable Wire instances. The wrappers changed here must define what an output context means for their destination and pass listener registration to the backing Wire.

Without this adapter-specific handling, HTTP can send later standalone requests without the context required to interpret them, while overwrite-mode files can appear to support context listeners even though the surviving file no longer contains that context.

Lifecycle decisions

  • String consumer: buffer clearing does not create a new output context, so context is emitted once before the first event.
  • Append file: appended documents share one output context and retain the first context record in the file.
  • Overwrite file: context listeners are rejected with an explanatory exception.
  • HTTP: each top-level writable document represents one POST. Its one-based context count advances only when that document opens, remains unchanged when it closes, and does not advance for a nested acquired document. After a successful POST, the backing Wire is reset so its listener is rearmed before the next document.

Stack position

This PR is stacked on #1272 and deliberately contains only concrete MarshallableOut adapter behaviour. It does not change the shared listener API or the core Wire lifecycle.

#1274 documents the completed Wire contract, and OpenHFT/Chronicle-Queue#1725 applies the same API to Queue roll cycles.

Review focus

Review the chosen output-context boundaries, HTTP open/close counting, reset-versus-clear behaviour, overwrite-file rejection, and the full-output assertions.

Validation

  • mvn -q -Dtest=DocumentContextLifecycleTest,MarshallableOutContextListenerTest test
  • mvn -q clean verify

@peter-lawrey
peter-lawrey force-pushed the feature/QUEUE-144-wire-context-listener-lifecycle branch from 10d25f3 to fd1fcb2 Compare August 7, 2026 09:23
@peter-lawrey
peter-lawrey force-pushed the feature/QUEUE-144-wire-marshallable-out-listeners branch from d08212f to 65323d6 Compare August 7, 2026 09:23
@peter-lawrey
peter-lawrey requested a lite review from Copilot August 7, 2026 12:52
@peter-lawrey
peter-lawrey marked this pull request as ready for review August 7, 2026 12:52
@peter-lawrey
peter-lawrey requested a review from tgd August 7, 2026 12:52
@peter-lawrey peter-lawrey self-assigned this Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Routes wire context-listener configuration through additional MarshallableOut implementations (string-consumer, file, HTTP) so context records can be emitted consistently across supported outputs and output-context lifecycles.

Changes:

  • Add contextListener(..) support to StringConsumerMarshallableOut, FileMarshallableOut (append-only), and HTTPMarshallableOut by delegating to the underlying Wire.
  • Update HTTP output lifecycle to treat each POST as a fresh output context (wire.reset() between successful POSTs) and expose a per-POST contextCount().
  • Add integration tests covering string-consumer, append-file, overwrite-file rejection, and HTTP POST behaviour.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/test/java/net/openhft/chronicle/wire/MarshallableOutContextListenerTest.java Adds coverage for context-listener behaviour across string-consumer, file (append/overwrite), and HTTP outputs.
src/main/java/net/openhft/chronicle/wire/internal/StringConsumerMarshallableOut.java Wires MarshallableOut.contextListener(..) through to the underlying Wire.
src/main/java/net/openhft/chronicle/wire/internal/HTTPMarshallableOut.java Adds per-POST output-context counting and resets the Wire between successful POSTs; wires through contextListener(..).
src/main/java/net/openhft/chronicle/wire/internal/FileMarshallableOut.java Supports contextListener(..) in append mode and rejects it in overwrite mode with a clear exception.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tgd
tgd requested a review from benbonavia August 10, 2026 16:54
@peter-lawrey
peter-lawrey force-pushed the feature/QUEUE-144-wire-context-listener-lifecycle branch from 3c4a997 to 5ab7b18 Compare August 11, 2026 09:07
@peter-lawrey
peter-lawrey force-pushed the feature/QUEUE-144-wire-marshallable-out-listeners branch from 96f45ed to adba541 Compare August 11, 2026 09:21
@peter-lawrey
peter-lawrey force-pushed the feature/QUEUE-144-wire-marshallable-out-listeners branch from adba541 to 9460790 Compare August 11, 2026 10:53
@peter-lawrey
peter-lawrey force-pushed the feature/QUEUE-144-wire-context-listener-lifecycle branch from 5ab7b18 to 751df01 Compare August 11, 2026 10:53
@peter-lawrey

Copy link
Copy Markdown
Member Author

Closed as deferred rather than merged. #1280 retains the supported Wire listener boundary while excluding the deferred adapter scope from this release.

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.

4 participants