Class RangedAcknowledger

java.lang.Object
com.amazon.sqs.javamessaging.acknowledge.BulkSQSOperation
com.amazon.sqs.javamessaging.acknowledge.RangedAcknowledger
All Implemented Interfaces:
Acknowledger

public class RangedAcknowledger extends BulkSQSOperation implements Acknowledger
Used to acknowledge group of messages. Acknowledging a consumed message acknowledges all messages that the session has consumed before and including that message.

A big backlog of consumed messages can cause memory pressure, as well as an increase on the probability of duplicates.

This class is not safe for concurrent use.

  • Constructor Details

  • Method Details

    • acknowledge

      public void acknowledge(SQSMessage message) throws jakarta.jms.JMSException
      Acknowledges all the consumed messages as well as the previously consumed messages on the session via calling deleteMessageBatch until all the messages are deleted.
      Specified by:
      acknowledge in interface Acknowledger
      Parameters:
      message - message to acknowledge.
      Throws:
      jakarta.jms.JMSException
    • notifyMessageReceived

      public void notifyMessageReceived(SQSMessage message) throws jakarta.jms.JMSException
      Updates the internal queue for the consumed but not acknowledged messages if the message was not already on queue.
      Specified by:
      notifyMessageReceived in interface Acknowledger
      Parameters:
      message - notify acknowledger message is received
      Throws:
      jakarta.jms.JMSException
    • getUnAckMessages

      public List<SQSMessageIdentifier> getUnAckMessages()
      Returns the list of all consumed but not acknowledged messages.
      Specified by:
      getUnAckMessages in interface Acknowledger
    • forgetUnAckMessages

      public void forgetUnAckMessages()
      Clears the list of not acknowledged messages.
      Specified by:
      forgetUnAckMessages in interface Acknowledger
    • action

      public void action(String queueUrl, List<String> receiptHandles) throws jakarta.jms.JMSException
      Acknowledges up to 10 messages via calling deleteMessageBatch.
      Specified by:
      action in class BulkSQSOperation
      Parameters:
      queueUrl - queueUrl of the queue, which the receipt handles belong
      receiptHandles - the list of handles, which is be used to (negative)acknowledge the messages.
      Throws:
      jakarta.jms.JMSException