Skip to content

Deserialize js message and ack #328

Answered by aricart
smiziara asked this question in Q&A
Jul 13, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

there are references to the client (for respond, etc) in the message, so not sure that serializing the actual js message is a good idea. Instead, you should be reading the payload/and headers if needed, and storing those (as that is your data).

If you want to ack the message, you can try (you may need to add a ):

// @ts-ignore: accessing internals
const nc // your nats connection
const reply = m.reply;
const sc = StringCodec();
nc.publish(reply, sc.encode("+ACK"));
// or 
nc.publish(reply, sc.encode("-NAK");

Note that if your operation takes longer than the amount configured to wait for acks, another client could have processed or reprocessed your message.

Not sure why the service that re…

Replies: 1 comment 2 replies

Comment options

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

@aricart
Comment options

Answer selected by smiziara
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