Example usage for com.amazonaws.services.sqs.model SendMessageRequest withMessageAttributes

List of usage examples for com.amazonaws.services.sqs.model SendMessageRequest withMessageAttributes

Introduction

In this page you can find the example usage for com.amazonaws.services.sqs.model SendMessageRequest withMessageAttributes.

Prototype


public SendMessageRequest withMessageAttributes(
        java.util.Map<String, MessageAttributeValue> messageAttributes) 

Source Link

Document

Each message attribute consists of a Name, Type, and Value.

Usage

From source file:org.springframework.cloud.aws.messaging.core.QueueMessageChannel.java

License:Apache License

@Override
protected boolean sendInternal(Message<?> message, long timeout) {
    try {//from   www .  j  av  a2 s  .c  o m
        SendMessageRequest sendMessageRequest = new SendMessageRequest(this.queueUrl,
                String.valueOf(message.getPayload())).withDelaySeconds(getDelaySeconds(timeout));
        Map<String, MessageAttributeValue> messageAttributes = getMessageAttributes(message);
        if (!messageAttributes.isEmpty()) {
            sendMessageRequest.withMessageAttributes(messageAttributes);
        }
        this.amazonSqs.sendMessage(sendMessageRequest);
    } catch (AmazonServiceException e) {
        throw new MessageDeliveryException(message, e.getMessage(), e);
    }

    return true;
}

From source file:support.SQS.java

License:Open Source License

public void sendMessage(String messageKeyValue, String textMessage) throws Exception {
    // Send a message
    System.out.println("Sending a message.\n");

    Map<String, MessageAttributeValue> messageAttributes = new HashMap<>();
    messageAttributes.put(message_attribute_name,
            new MessageAttributeValue().withDataType("String").withStringValue(messageKeyValue));

    SendMessageRequest request = new SendMessageRequest();
    request.withMessageBody(textMessage);
    request.withQueueUrl(send_queue_url);
    request.withDelaySeconds(delay_time);
    request.withMessageAttributes(messageAttributes);
    sqs.sendMessage(request);/*from  www . j  a  v a  2  s. c  o  m*/
}