Skip to content

JetStream subcribe to Dead Letter Queue #423

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

You must be logged in to vote

you can get directly from the stream. note message data is base64 encoded:

// equivalent of `nats stream get EVENTS 1`

await using var nats = new NatsConnection();
var js = new NatsJSContext(nats);
var stream = await js.GetStreamAsync("EVENTS");

var msg = await stream.GetAsync(new StreamMsgGetRequest { Seq = 1 });

var time = DateTimeOffset.Parse(msg.Message.Time);
var subject = msg.Message.Subject;
var data = Encoding.ASCII.GetString(Convert.FromBase64String(msg.Message.Data));

Console.WriteLine($"received {time} on {subject}:");
Console.WriteLine(data);

Replies: 4 comments 11 replies

Comment options

You must be logged in to vote
2 replies
@alberk8
Comment options

@mtmk
Comment options

mtmk Mar 2, 2024
Maintainer

Answer selected by alberk8
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@mtmk
Comment options

mtmk Mar 4, 2024
Maintainer

@alberk8
Comment options

@robertmircea
Comment options

@mtmk
Comment options

mtmk Mar 4, 2024
Maintainer

@mtmk
Comment options

mtmk Mar 4, 2024
Maintainer

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