Receives messages from the queue.

public static LrSqsMessage receiveMessage()

public static List<LrSqsMessage> receiveMessages(int maxNumberOfMessages)

public static List<LrSqsMessage> receiveMessages(int maxNumberOfMessages, int waitTimeSeconds)


maxNumberOfMessagesThe maximum number of messages to receive.
waitTimeSecondsThe maximum number of seconds to wait for the messages.

Return values

This function returns an LrSqsMessage object or a list of LrSqsMessage objects. If the queue is empty and there are no messages to be retrieved, the returned value is null.

General information

If no arguments are used for this API, the function retrieves only one message.

The waitTimeSeconds argument is used to wait for messages if they are not currently available. This creates the long polling effect. For details about this effect, see the Amazon SQS documentation.

You can specify any number of messages to receive and any amount of time to wait. The function will send one or more requests, each attempting to receive at most 10 messages or waiting for at most 20 seconds.


Copy code
public void receiveMessageTest(){
        LrSqsClient.initClient(region, standardQueueUrl);
        LrSqsMessage message = LrSqsClient.receiveMessage();
        lr.output_message("Got 1 message: " + message.body());
        List<LrSqsMessage> collection = LrSqsClient.receiveMessages(5, 20);
        for (LrSqsMessage m : collection) {
            lr.output_message("Got message in collection: " + m.body());
        List<LrSqsMessage> collectionEx =   LrSqsClient.receiveMessagesEx(3, 20, null, null, new ArrayList() {{ add("MessageGroupId"); }}, null);
        for (LrSqsMessage m : collectionEx) {
            String messageGroupId = m.systemAttributesAsStrings().get("MessageGroupId");
            lr.log_message("Got message in collectionEX: " + messageGroupId + " " + m.body());
        LrSqsDeleteMessageBatchRequestStatus status = LrSqsClient.deleteMessageBatch(collectionEx);