LrSqsClient.sendMessageEx

Sends a message with multiple attributes to the queue.

public static LrSqsSendMessageResult sendMessageEx(String messageBody, Integer delaySeconds, Map<String, LrSqsMessageAttributeValue> messageAttributes)

public static LrSqsSendMessageResult sendMessageEx(String messageBody, String messageGroupId, String deduplicationId, Map<String, LrSqsMessageAttributeValue> messageAttributes)

Arguments

NameDescription
messageBodyThe message body to be sent.
messageGroupIdThe message group to which the message belongs.
messageDeduplicationIdThe deduplication ID of the message.
delaySecondsThe delay (in seconds) between when the message is sent and when the message appears in the queue.
messageAttributesUser-defined attributes for the message to be sent, specified as key-value pairs.

Return values

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

General information

This function sends a specific message to the queue. It allows the message to be constructed with user-defined attributes. The messageAttributes parameter can be null if user-defined attributes are not required.

If the message group ID and deduplication ID arguments are used, the queue must be of the type FIFO (first in first out). Otherwise, the message queue must be standard.

Example

Copy code
public void sendMessageEx(){

    HashMap<String, LrSqsMessageAttributeValue> messageAttributes = new HashMap<String, LrSqsMessageAttributeValue>();
    messageAttributes.put("attrib1", LrSqsClient.createMessageAttributeValueString("my string attribute"));
    messageAttributes.put("attrib2", LrSqsClient.createMessageAttributeValueInt("1234"));
    messageAttributes.put("attrib3", LrSqsClient.createMessageAttributeValueInt(5678));
    messageAttributes.put("attrib4", LrSqsClient.createMessageAttributeValueDouble(56.78));
    messageAttributes.put("attrib5", LrSqsClient.createMessageAttributeValueBinary("string binary to bytes".getBytes()));
    messageAttributes.put("attrib6", LrSqsClient.createMessageAttributeValueBinary("string binary value"));
        
    LrSqsClient.initClient(region, standardQueueUrl);
    LrSqsClient.sendMessageEx("MessageBody1", 0, messageAttributes);

    LrSqsClient.closeClient();
  
 }