Manual Acknowledgment
To manually acknowledge processed messages and remove the messages from
the queue, applications use the sow_delete
command with the
bookmarks of the messages to remove. Notice that AMPS only supports
using a bookmark with sow_delete
when removing messages from a
queue, not when removing records from a SOW.
For example, given a Message
object to acknowledge and a client, the
code below acknowledges the message.
const acknowledgeSingle = async (client, message) => {
return client.execute(
new Command('sow_delete')
.topic(message.header.topic())
.bookmark(message.header.bookmark());
);
};
In the example above, the program creates a sow_delete
command,
specifies the topic and the bookmark, and then sends the command to
the server.
While this method works, creating and sending an acknowledgment for
each individual message can be inefficient if your application is
processing a large volume of messages. Rather than acknowledging each
message individually, your application can build a comma-delimited list
of bookmarks from the processed messages and acknowledge all of the
messages at the same time. In this case, it's important to be sure that
the number of messages you wait for is less than the maximum backlog --
the number of messages your client can have unacknowledged at a given
time. Notice that both automatic acknowledgment and the convenience
method Client.ack()
take the maximum backlog into account.