Skip to content

ack a message from jetstream consumer in a different context from the one that received the message from nats server #579

Closed Answered by aricart
fogine asked this question in Q&A
Discussion options

You must be logged in to vote

Sure you can! - and for that reason, any of the other operations as well (have a look at

export const ACK = Uint8Array.of(43, 65, 67, 75);
for the payloads etc).

In a nutshell, you'll need to "grab" the embedded nats message that is wrapped by JsMsg, get the reply subject from it, and then publish a message to the reply subject with the payload +ACK:

  const name = nuid.next();
  const jsm = await nc.jetstreamManager();
  await jsm.streams.add({
    name,
    subjects: [name],
    storage: StorageType.Memory,
    retention: RetentionPolicy.Workqueue,
  });

  const js = nc.jetstream();
  await js.publish(name);
  let si = await

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by aricart
Comment options

You must be logged in to vote
0 replies
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