Skip to content

Ability to supply a prefix for watches. Fixed ordered consumer naming bug. #1314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

scottf
Copy link
Contributor

@scottf scottf commented May 13, 2025

Overview

  • Original Ordered Push Consumers that can supply a name, but that name is used as a prefix.
  • Key Value and Object Store watchers can supply a consumer name prefix via their implementation of Watcher
  • Simplified ordered consumers can supply a consumer name prefix in OrderedConsumerConfiguration

Per file change Notes

These files only changes are api documentation or comment cleanup.

  • BaseConsumeOptions.java
  • BaseConsumerContext.java
  • KeyValueManagement.java
  • MessageConsumer.java
  • SubscribeOptions.java

OrderedConsumerConfiguration.java

  • is mostly documentation but one important api change, the addition of
    • public OrderedConsumerConfiguration consumerNamePrefix(String consumerNamePrefix)

Watcher.java

  • adds a new interface method with a default. This is what allows a KV or OS watcher to supply a prefix.
    • default String getConsumerNamePrefix()

NatsConsumerContext.java

  • applies the consumerNamePrefix from the OrderedConsumerConfiguration
  • records the consumer name in the context
  • updates the behavior of the next(...) implementation to record the consumer name

NatsJetStream.java

  • Code here now is ordered aware. When ordered, it automatically changes a consumer name into a prefix and makes sure that name is used to create the physical consumer. This is the code that actually creates a consumer on subscribe so this change will affect all ordered consumers.

NatsJetStreamImpl.java

  • simplified consumerConfigurationForOrdered, recognizing the change in NatsJetStream

NatsKeyValueWatchSubscription.java and NatsObjectStoreWatchSubscription.java

  • passes the prefix to code that completes initialization of the watcher

NatsMessageConsumerBase.java

  • properly manages the knowledge of the consumer name in simplification

NatsWatchSubscription.java

  • uses the consumer name prefix as the consumer config name, which NatsJetStream turns into a prefix now that it is ordered aware

OrderedMessageManager.java

  • remove code to delete an existing consumer, since this can fail. Not needed anymore since NatsJetStream ensures a unique name for all ordered consumers.

PushMessageManager.java

  • renamed a variable - nothing functional

NatsJetStreamUtil.java

  • New class - currently has helper functions to create consumer names

Tests

  • JetStreamConsumerTests.java
  • JetStreamGeneralTests.java
  • KeyValueTests.java
  • SimplificationTests.java
  • TestBase.java

* Original Ordered Push Consumers can supply a name.
* Key Value and Object Store watchers can supply a name
* Simplified ordered consumers can supply a prefix in OrderedConsumerConfiguration
@scottf scottf marked this pull request as draft May 13, 2025 13:41
@scottf scottf changed the title Ability to supply a name for an ordered consumer. Ability to supply a prefix for watches May 19, 2025
@scottf scottf marked this pull request as ready for review May 21, 2025 14:59
@scottf scottf requested a review from MauriceVanVeen May 21, 2025 15:49
@scottf scottf changed the title Ability to supply a prefix for watches Ability to supply a prefix for watches. Fixed ordered consumer naming bug. May 21, 2025
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.

1 participant