Skip to content

Difference between SubscribeAsync vs ConsumeAsync in jetstream context #669

Answered by mtmk
YashasAnand asked this question in Q&A
Discussion options

You must be logged in to vote

you'd need to use different subjects e.g. orders.> could be ones you want to persist and set up as part of a ORDERS stream and events.> could be for just plain NATS core messages and not configured in any stream.

it's like layers. JetStream is built on top of NATS Core and you can observe messages being published by subscribing to the same subjects as streams configured to persist. but unless you use a consumer to get those messages from a stream they won't be taken out of a work queue stream for example.

// dotnet add package NATS.Net
using NATS.Client.JetStream;
using NATS.Client.JetStream.Models;
using NATS.Net;

var stop = new CancellationTokenSource();

await using var client = new N…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@YashasAnand
Comment options

@mtmk
Comment options

mtmk Nov 5, 2024
Maintainer

Answer selected by YashasAnand
@YashasAnand
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants