You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preview release of JetStream.Publisher adding end-of-batch sentinel support to NatsJSBatchPublisher. Requires NATS Server 2.14+ for the new CloseAsync path.
Gather context: examine PR diff and relevant source files
Review version change
Review the batch publisher changes referenced in the PR
Post review summary
Summary
The PR itself is a single-line version bump (1.0.0-preview.6 → 1.0.0-preview.7). The substantive change is in the referenced commit (e19e066), which added CloseAsync — an end-of-batch (EOB) sentinel path to NatsJSBatchPublisher.
CloseAsync / EOB Implementation
Correctness looks good:
The _sequence counter is intentionally not incremented for the EOB sentinel (line 279–281 in NatsJSBatchPublisher.cs), so Size stays consistent with ack.BatchSize. The expectedSize validation at line 325 (currentSeq - 1 for EOB) correctly checks this invariant.
_closed = true is set inside CommitMsgInternalAsync's lock section (line 275) before any network I/O, so concurrent CloseAsync calls are safe: the loser sees _closed = true and throws NatsJSBatchClosedException.
Empty-batch guard (_sequence == 0 || _batchSubject == null) is defensive and correct; the failed CloseAsync leaves the batch open for subsequent use as verified by the test at line 646–650.
The Nats-Batch-Commit: eob header value is clearly documented in NatsJSBatchHeaders.BatchCommit.
One minor observation:
CloseAsync sends the sentinel on _batchSubject (the subject of message 1). For multi-subject batches the interface docs note this explicitly, but callers using entirely different subjects for every message might find it unexpected. This is a documentation/design trade-off rather than a bug, and the current docs cover it.
Test coverage is thorough: basic close, Size == ack.BatchSize consistency, empty-batch guard, close-after-close, and close-after-commit are all exercised with server-version guards for the 2.14+ EOB path.
Version Bump
version.txt change is correct and consistent with a preview release following the feature merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preview release of JetStream.Publisher adding end-of-batch sentinel support to
NatsJSBatchPublisher. Requires NATS Server 2.14+ for the newCloseAsyncpath.