Share this page

# LrSqsClient.sendMessage

Sends a message to the queue.

`public static LrSqsSendMessageResult sendMessage(String messageBody)`

`public static LrSqsSendMessageResult sendMessage(String messageBody, String messageGroupId)`

`public static LrSqsSendMessageResult sendMessage(String messageBody, String messageGroupId, String messageDeduplicationId)`

## Arguments

Name | Description
--- | ---
messageBody | The message body to be sent.
messageGroupId | The message group to which the message belongs.
messageDeduplicationId | The deduplication ID of the message.

## Return values

This function returns an LrSqsSendMessageResult object. For details, see LrSqsSendMessageResult.

## General information

This function sends a specific message to the queue.

If the message is specified only by its body, the queue must be a standard one. If the message also has other attributes - group ID or deduplication ID - the queue must be of the type FIFO (first in first out).

Group ID is an attribute that is used to send the message to a specific group. Within a group, the messages are consumed in strict order.

AWS FIFO queues do not accept duplicates that are sent in a small interval of time. The duplication is verified according to the deduplication ID. If a message with a deduplication ID is sent successfully, another message with the same ID will be accepted, but only if at least 5 minutes have passed since the first message.

## Example

Copy code

    public int action() throws Throwable {

        String standardQueueUrl = "https://sqs.eu-central-1.amazonaws.com/123456789/jsmith-sqs0";
        String fifoQueueUrl = "https://sqs.eu-central-1.amazonaws.com/123456789/jsmith-sqsfifo0.fifo";
        LrAwsRegion region = LrAwsRegion.EU_CENTRAL_1;

        LrSqsClient.initClient(region, standardQueueUrl);

        LrSqsSendMessageResult result1 = LrSqsClient.sendMessage("hi");
        lr.output_message("message ID: " + result1.messageId());

        LrSqsClient.resetQueueUrl(fifoQueueUrl);

        result1 = LrSqsClient.sendMessage("hi", "group0", "1");
        lr.output_message("message ID: " + result1.messageId());
        lr.output_message("sequenceNumber: " + result1.sequenceNumber());

        LrSqsClient.closeClient();

        return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: