LrSqsMessage.hasAttributes

Returns a Boolean value that shows whether the message has user-defined attributes.

public final bool hasAttributes()

Return values

This function returns true if the current message has user-defined attributes or false otherwise.

Example

Copy code
public void sendMessageByBatch_FIFO(){
 LrSqsClient.initClient(region, fifoQueueUrl);
        LrSqsClient.initMessageBatch();
        LrSqsClient.addMessageToBatch("batch message 0", "group1", "dup1");
        LrSqsClient.addMessageToBatch("batch message 1", "group1", "dup2");
        
        HashMap<String, LrSqsMessageAttributeValue> messageAttributes = new HashMap<String, LrSqsMessageAttributeValue>()
        messageAttributes.put("attr1", LrSqsClient.createMessageAttributeValueString("my string attribute value"));
        messageAttributes.put("attr2", LrSqsClient.createMessageAttributeValueInt("1234"));
        
        LrSqsClient.addMessageToBatchEx("batch message 3", "group1", "dup3", "idInBatch1", messageAttributes);
        
        LrSqsSendMessageBatchRequestStatus batchResponse = LrSqsClient.sendMessageBatch();
        Collection<LrSqsSendMessageBatchStatusEntry> succesfull_res = batchResponse.successful();
                
        for (LrSqsSendMessageBatchStatusEntry entry : succesfull_res){
            lr.output_message("Message sent successfully: " + entry.messageId());
        }
        
        LrSqsClient.closeClient();
}