Is it possible to manually acknowledge delivered message stream sequence in a separate request (independent on the request receiving the message) to the nats server?
Usually you would receive messages from a consumer, process them and ack them in a single defined context:
const messages = await consumer.consume({ max_messages: maxMessages });
for await (const m of messages) {
//some process logic
await m.ack();
}
In my use case I want to bridge http API with a nats stream of messages.
I defined two http endpoints:
- GET /events
which would pull messages from a pull consumer.
- POST /events/ack?lastReceivedEventSeqId=10
which would acknowledge with the nats
server that the messages up to the message with sequence id 10
have been successfully processed.
The issue is I can not ack
a message after I loose the context that initially received the message from nats server.
//inside implementation of GET /events/ack endpoint`
const s : Stream | undefined = await jetstream.streams.get('mystream');
const message = await s.getMessage({seq: 10});
//message has no `ack` method