Counter support for server v2.12#960
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements JetStream message counter support for NATS server v2.12, enabling streams to track and increment/decrement counters via message headers. The implementation follows ADR-49 specifications by adding configuration options and response value handling.
- Added
AllowMsgCounterproperty toStreamConfigfor enabling counter functionality - Enhanced
PubAckResponseto include counter value in publish acknowledgments - Comprehensive test coverage for counter operations and error scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/NATS.Client.JetStream/Models/StreamConfig.cs | Adds AllowMsgCounter boolean property to enable message counters in stream configuration |
| src/NATS.Client.JetStream/Models/PubAckResponse.cs | Adds optional Value property to return counter values in publish acknowledgments |
| tests/NATS.Client.JetStream.Tests/CounterTest.cs | Implements comprehensive test suite covering counter operations, error handling, and feature validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Closed
mtmk
deleted the
2.12/support-for-JetStream-Distributed-Counter-CRDT
branch
September 25, 2025 08:45
mtmk
commented
Sep 30, 2025
| /// <remarks>Supported by server v2.12</remarks> | ||
| [System.Text.Json.Serialization.JsonPropertyName("allow_msg_counter")] | ||
| [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] | ||
| public bool AllowMsgCounter { get; set; } |
mtmk
added a commit
that referenced
this pull request
Oct 1, 2025
Merged
mtmk
added a commit
that referenced
this pull request
Oct 1, 2025
This was referenced Mar 2, 2026
This was referenced Jul 13, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Support implementation of ADR-49
This pull request adds support for the JetStream message counter feature introduced in NATS server v2.12. It introduces a new property to enable message counters in stream configurations, updates the publish acknowledgment response to include the counter value, and adds comprehensive tests to verify the new functionality and error handling.
JetStream message counter support:
AllowMsgCounterproperty to theStreamConfigmodel, allowing streams to enable or disable message counters. This property is serialized asallow_msg_counterand is supported from server v2.12.PubAckResponsemodel to include an optionalValueproperty (serialized asval), which returns the current counter value when publishing messages with counter headers.Testing:
CounterTestclass to verify message counter functionality, including incrementing, decrementing, using multiple counters, and ensuring proper error handling when the feature is disabled.