code: public void bulkAction(List<SQSMessageIdentifier> messageIdentifierList, int indexOfMessage)
              throws JMSException {
  
          assert indexOfMessage > 0;
          assert indexOfMessage <= messageIdentifierList.size();
  
          Map<String, List<String>> receiptHandleWithSameQueueUrl = new HashMap<String, List<String>>();
          
          // Add all messages up to and including requested message into Map.
          // Map contains key as queueUrl and value as list receiptHandles from
          // that queueUrl.
  
          for (int i = 0; i < indexOfMessage; i++) {
              SQSMessageIdentifier messageIdentifier = messageIdentifierList.get(i);
              String queueUrl = messageIdentifier.getQueueUrl();
              List<String> receiptHandles = receiptHandleWithSameQueueUrl.get(queueUrl);
              // if value of queueUrl is null create new list.
              if (receiptHandles == null) {
                  receiptHandles = new ArrayList<String>();
                  receiptHandleWithSameQueueUrl.put(queueUrl, receiptHandles);
              }
              // add receiptHandle to the list.
              receiptHandles.add(messageIdentifier.getReceiptHandle());
              // Once there are 10 messages in messageBatch, apply the batch action
              if (receiptHandles.size() == SQSMessagingClientConstants.MAX_BATCH) {
                  action(queueUrl, receiptHandles);
                  receiptHandles.clear();
              }
          }
  
          // Flush rest of messages in map.
          for (Entry<String, List<String>> entry : receiptHandleWithSameQueueUrl.entrySet()) {
              action(entry.getKey(), entry.getValue());
          }
      }
docs: Bulk action on list of message identifiers up to the provided index
  
  @param messageIdentifierList
  Container for the list of message identifiers
  @param indexOfMessage
  The action will apply to all messages up to this index
  @throws JMSException
  if <code>action</code> throws