question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to create an ephemeral pull consumer

See original GitHub issue

Defect

I am trying to create a pull subscription with ephemeral consumer using the following code:

var cc = ConsumerConfiguration.Builder()
    .WithMaxAckPending(20)
    .WithAckWait(Duration.OfSeconds(40))
    .WithMaxDeliver(1)
    .WithReplayPolicy(ReplayPolicy.Instant)
    .WithFilterSubject("auditevents")
    .Build();
jetStreamManagementContext.AddOrUpdateConsumer("auditevents", cc);

The JetStreamManagement.AddOrUpdateConsumer always verifies if Durable name is set and it is impossible to create an ephemeral consumer using any other method from JetStreamManagement.

public ConsumerInfo AddOrUpdateConsumer(
  string streamName,
  ConsumerConfiguration config)
{
  Validator.ValidateStreamName(streamName, true);
  Validator.ValidateNotNull((object) config, nameof (config));
  Validator.ValidateNotNull(config.Durable, "Durable");
  return this.AddOrUpdateConsumerInternal(streamName, config);
}

Versions of NATS.Client and nats-server:

Client: 0.14.6 Server: 2.8.4

OS/Container environment:

MacOs Monterey

Expected result:

Possibility to create a Jetstream pull subscription with ephemeral consumer.

Actual result:

System.ArgumentNullException: Value cannot be null. (Parameter 'Durable')
   at NATS.Client.Internals.Validator.ValidateNotNull(String s, String fieldName)
   at NATS.Client.JetStream.JetStreamManagement.AddOrUpdateConsumer(String streamName, ConsumerConfiguration config)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
scottfcommented, May 27, 2022

@robertmircea I’m waiting for this PR to be merged (https://github.com/nats-io/nats.net/pull/605), then you will be able to create ephemeral pulls.

0reactions
scottfcommented, Jun 19, 2022

Ephemeral consumers cannot be created ahead of time using management, they can only be created during the subscribe call. Please see this example and comment out the durable: https://github.com/nats-io/nats.net/blob/master/src/Samples/JetStreamPullSubBatchSize/JetStreamPullSubBatchSize.cs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consumer Details - NATS Docs
You (automatically) create an ephemeral consumer when you call the js.Subscribe function without specifying the Durable or Bind subscription options.
Read more >
Creating consumer without/wrong durable name fails #3821
A consumer is considered durable when an explicit name is set on the Durable field when creating the consumer, otherwise it is considered...
Read more >
NATS by Example - Pull Consumers (Go)
A pull consumer allows for the application to fetch one or more messages on-demand using a subscription bound to the consumer. This allows...
Read more >
Message still in nats limit queue after ack and term sent in Go
Here is what I believe happens in your code: When you call the SubscribeSync method, an ephemeral consumer is created, with your provided...
Read more >
ConsumerConfig in nats::jetstream - Rust
Setting deliver_subject to None will cause this consumer to be “pull-based”, and will require explicit acknowledgment of each message. This is analogous in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found