Set ConsumerConfig.Name so NATS accepts consumer creation
NATS.Net 2.5 posts CreateOrUpdateConsumerAsync to $JS.API.CONSUMER.CREATE.<stream>.<name>, pulling <name> from ConsumerConfig.Name. The server compares that against DurableName in the payload and rejects the request with "consumer name in subject does not match durable name in request" when Name is missing. Set both properties to the same value so durable consumer creation succeeds and messages actually reach the dispatcher.
This commit is contained in:
@@ -117,6 +117,11 @@ public sealed class NatsTriggerHostedService(
|
||||
|
||||
var consumer = await js.CreateOrUpdateConsumerAsync(stim.Stream, new ConsumerConfig
|
||||
{
|
||||
// NATS.Net 2.5 sends the create request to $JS.API.CONSUMER.CREATE.<stream>.<name>,
|
||||
// pulling <name> from Name. Server compares it against DurableName in the payload
|
||||
// and returns "consumer name in subject does not match durable name in request" if
|
||||
// Name is missing. Set both to the same value.
|
||||
Name = consumerName,
|
||||
DurableName = consumerName,
|
||||
AckPolicy = ConsumerConfigAckPolicy.Explicit,
|
||||
DeliverPolicy = ConsumerConfigDeliverPolicy.New, // only applied on first-time creation
|
||||
|
||||
Reference in New Issue
Block a user