How to find number of subscriptions on jetstream #6117
-
I am using jetsream but instead of consuming messages I am subscribing to subjects with queue groups attached. If i do nats consumer list i do not get list of consumers. If so how do i get number of subscribers? I have tried to look in management console on 8222 port, but i do not get details like if its my own subscriptios or some server subscriptions as the numbers are not matching. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
In JetStream, you cannot subscribe to Stream Subjects without a Consumer, so you definately should see consumers in consumer list. In CLI, you can use |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply @Jarema , pls see the attached screenshots of nats consumer report & nats stream report I am using below snippet of code to do these operations. Is this a bug? Pls refer to code below: NatsOpts natsOptions = new NatsOpts
{
Url = connectionInfo.BrokerUrl,
Name = connectionInfo.ClientName,
};
_natsConnection = new NatsConnection(natsOptions);
_natsJSContext = new NatsJSContext(_natsClient);
await foreach (var msg in _natsClient.SubscribeAsync(natsConsumerOptions.TopicName,natsConsumerOptions.ConsumerGroup,serializer:natsMesgSerializer))
{
_logger.Log($"Received message on Subscriber {natsConsumerOptions.TopicName} in group {natsConsumerOptions.ConsumerGroup}: {msg.Data}");
_ = Task.Run(async () => await ProcessMessageAsyncNew(natsConsumerOptions,consumerOptions,onMessageReceived,msg));
} |
Beta Was this translation helpful? Give feedback.
-
Ah I see, @Jarema thank you for pointing this out, but then how are the messages still persisiting to stream if i am not using jetstream context? |
Beta Was this translation helpful? Give feedback.
-
@Jarema thank you so much for your help. Much Aprreciated !! |
Beta Was this translation helpful? Give feedback.
you can publish messages to the stream with just Core NATS, but you will not get ACK, not a backpressure control (so it's not a good idea).
JetStream Publish sends a request instead, that will expect ack back.