nats-io / nats.net.v2

Full Async C# / .NET client for NATS

Home Page:https://nats-io.github.io/nats.net.v2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JetStream Backoff

alberk8 opened this issue · comments

Observed behavior

With code below it looks like the backoff is not in effect. Also there is no reference anywhere in the source.

Expected behavior

Backoff Setting works

Server and client version

Server: v2.10.11
Client: NATS.Client.JetStream v2.1.2

Host environment

Official NATS docker (latest) with JetStream enabled.

Steps to reproduce

var consumer = await jsContext.CreateOrUpdateConsumerAsync("EVENTS", new ConsumerConfig(consumerName)
{
    DeliverPolicy = ConsumerConfigDeliverPolicy.All,
    FilterSubject = "data.>",
    AckPolicy = ackPolicy,
    AckWait = ackWait,
    
    MaxDeliver = 5,
    Backoff = new List<long>() { (long) TimeSpan.FromSeconds(1).TotalSeconds, (long)TimeSpan.FromSeconds(2).TotalSeconds }
});

 await foreach (NatsJSMsg<Person> msg in consumer.ConsumeAsync<Person>())
 {
     Console.WriteLine($"Subject: {msg.Subject} Size: {msg.Size}");
     var md = msg.Metadata;
     if (md.HasValue)
     {
        Console.WriteLine($"Num Delivered: {md.Value.NumDelivered} TimeStamp: {md.Value.Timestamp.ToLocalTime()}");
        Console.WriteLine($"Consumer Seq: {md.Value.Sequence.Consumer} Stream Seq: {md.Value.Sequence.Stream}");
     }
     await msg.NakAsync();
 }
commented

it might be nanoseconds, could you try that?
We changed everything to be TimeSpan but missed this one I think 🤔

I have changed to MicroSeconds and there is no difference. The Re-Delivery went through in quick succession.

Looking at the source code, it does not seems that Backoff is implemented.

commented

I have changed to MicroSeconds and there is no difference. The Re-Delivery went through in quick succession.

it's should be nano .. another x1000

Looking at the source code, it does not seems that Backoff is implemented.

I think this is just passed to the server, I don't think there is anything to implement on client side, is there?

Thanks. I really missed it. Nanoseconds did the trick. It is working as expected.