-
Hello Guys, We have a scenario here that we receive Jetstream messages, and have to serialize them. Later we need to deserialize and Ack or Nack the message. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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 receives the message cannot await a response from your downstream or simply process your payload, and simply ack. |
Beta Was this translation helpful? Give feedback.
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 ):
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…