Redelivery with consumer queue groups
See original GitHub issueI’m testing JetStream consumer groups and I have a question regarding the redelivery. I’m using nats-server: v2.6.0
and nats.js: v2.2.0
My scenario looks like this:
In this scenario the publisher creates a burst of 10 messages ({ id: 0 }
, …, { id: 9 }
).
Expected behavior All messages that sub1 rejects to be redelivered.
Actual behavior Some of the messages being redelivered.
Here are consumerOpts
of each subscription
sub1
ConsumerOptsBuilderImpl {
stream: '',
mack: true,
config: {
name: '',
deliver_policy: 'new',
ack_policy: 'all',
ack_wait: 30000000000,
replay_policy: 'instant',
deliver_group: 'test_unstable_topic',
durable_name: 'mygroup',
deliver_subject: 'sub1.test.unstable.topic',
max_deliver: 5
},
qname: 'test_unstable_topic',
callbackFn: [AsyncFunction (anonymous)]
}
sub 2
ConsumerOptsBuilderImpl {
stream: '',
mack: true,
config: {
name: '',
deliver_policy: 'new',
ack_policy: 'all',
ack_wait: 30000000000,
replay_policy: 'instant',
deliver_group: 'test_unstable_topic',
durable_name: 'mygroup',
deliver_subject: 'sub2.test.unstable.topic',
max_deliver: 5
},
qname: 'test_unstable_topic',
callbackFn: [AsyncFunction (anonymous)]
}
The consumerOpt.callback()
is defined here: https://github.com/moleculerjs/moleculer-channels/blob/e61c4596db6d57145e960b785fb85868737326fa/src/adapters/nats.js#L173-L247
and here are the logs:
Logs explanation:
{ id: 0 }
- delivered to sub1, got “NACKed” viamessage.nack()
and was NOT redelivered.{ id: 1 }
- delivered to sub2 and logged successfully{ id: 2 }
- delivered to sub2 and logged successfully{ id: 3 }
- delivered to sub2 and logged successfully{ id: 4 }
- delivered to sub2 and logged successfully{ id: 5 }
- delivered to sub2 and logged successfully{ id: 6 }
- delivered to sub2 and logged successfully{ id: 7 }
- delivered to sub1, got “NACKed” viamessage.nack()
and was redelivered again to sub1 and got “NACKed” again. However, after that it was not redelivered. Even with themax_deliver: 5
set.{ id: 8 }
- delivered to sub1, got “NACKed” viamessage.nack()
and was redelivered to sub2 and then logged successfully{ id: 9 }
- delivered to sub1, got “NACKed” viamessage.nack()
and was redelivered to sub2 and then logged successfully
My question is regarding the messages with id=0, id=7, id=8 and id=9. Can you explain why their behavior differs? Is this a config issue?
Also, how the load balancing is being done in JetStream? I didn’t find any info about it in the docs.
The only reference I found was in Queue Groups which states that one member of the group is chosen randomly to receive the message
However, in the image below the message is being constantly redelivered to the same consumer. It seems that load balancing is not working properly
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Ups, sorry.
After resetting the server, things seem to be working fine
Here’s my consumer info:
and stream info
Thank you for the help 👍
Grab the consumer configuration by asking for it, also list the number of consumers for the stream, there should be one - on your config there you have different delivery subjects, but they are not. The durable is written with the first deliver_to, and when the client grabs the consumer, it uses whatever is already on the server.