Skip to content

Conversation

@mtmk
Copy link
Member

@mtmk mtmk commented Dec 1, 2025

This pull request adds support for the ExpectedLastSubjectSequenceSubject option to JetStream publish operations, allowing users to specify a subject filter (including wildcards) for expected last subject sequence checks. This enables more flexible conditional publishing based on the last sequence of a specific subject. The changes also include a new test to verify the correct behavior of this feature.

JetStream publish options enhancements

  • Added a new property ExpectedLastSubjectSequenceSubject to the NatsJSPubOpts record, allowing users to specify a subject filter for expected last subject sequence checks.
  • Updated both TryPublishAsync<T> and PublishConcurrentAsync<T> methods in NatsJSContext.cs to include the Nats-Expected-Last-Subject-Sequence-Subject header when ExpectedLastSubjectSequenceSubject is set. [1] [2]

Testing improvements

  • Added a new test Publish_expected_last_subject_sequence_subject_test to verify that publishing with the ExpectedLastSubjectSequenceSubject option works as expected, including handling of correct and stale sequence numbers.

@mtmk mtmk requested a review from scottf December 1, 2025 13:50
Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

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

LGTM

@mtmk mtmk merged commit af50d8b into main Dec 2, 2025
24 of 25 checks passed
@mtmk mtmk deleted the add-Nats-Expected-Last-Subject-Sequence-Subject-header branch December 2, 2025 11:28
mtmk added a commit that referenced this pull request Dec 11, 2025
* Add prioritized mode (#1011)
* Add Publish Timeout on Disconnect (#1001)
* Fix test flap (#1012)
* Add test to promote mirrored to regular stream (#1008)
* Add Nats-Expected-Last-Subject-Sequence-Subject (#1007)
* Fix keyed NATS clients with configurations (#1006)
* ensure NatsConnectionPool cannot overflow (#1005)
* Fix stream config adjustments on update (#995)
* Handel Unobserved Exceptions During Connection State Transitions (#999)
* Added verification of the consumer sequence number for pull ordered consumers (#981)
* Fix build warnings (#991)
* Reduce closure allocations (#988)
@mtmk mtmk mentioned this pull request Dec 11, 2025
mtmk added a commit that referenced this pull request Dec 11, 2025
* Add prioritized mode (#1011)
* Add Publish Timeout on Disconnect (#1001)
* Fix test flap (#1012)
* Add test to promote mirrored to regular stream (#1008)
* Add Nats-Expected-Last-Subject-Sequence-Subject (#1007)
* Fix keyed NATS clients with configurations (#1006)
* ensure NatsConnectionPool cannot overflow (#1005)
* Fix stream config adjustments on update (#995)
* Handel Unobserved Exceptions During Connection State Transitions (#999)
* Added verification of the consumer sequence number for pull ordered consumers (#981)
* Fix build warnings (#991)
* Reduce closure allocations (#988)
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.

3 participants