Example usage for com.amazonaws.services.sqs.model Message getMD5OfMessageAttributes

List of usage examples for com.amazonaws.services.sqs.model Message getMD5OfMessageAttributes

Introduction

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

Prototype


public String getMD5OfMessageAttributes() 

Source Link

Document

An MD5 digest of the non-URL-encoded message attribute string.

Usage

From source file:com.streamsets.pipeline.stage.origin.sqs.SqsConsumerWorkerCallable.java

License:Apache License

private void setSqsAttributesOnRecord(Message message, Record record, String queueUrl, String queueNamePrefix) {
    final Record.Header header = record.getHeader();

    switch (sqsAttributesOption) {
    case ALL://from  w  w w  .  j  a  v  a  2s  .c om
        header.setAttribute(SQS_QUEUE_URL_ATTRIBUTE, queueUrl);
        Optional.of(message.getMessageAttributes()).ifPresent(attrs -> {
            attrs.forEach((name, val) -> {
                final String stringValue = val.getStringValue();
                if (stringValue != null) {
                    header.setAttribute(SQS_MESSAGE_ATTRIBUTE_PREFIX + name, stringValue);
                }
            });
        });
        final String body = message.getBody();
        if (body != null) {
            header.setAttribute(SQS_MESSAGE_BODY_ATTRIBUTE, body);
        }
        final String bodyMd5 = message.getMD5OfBody();
        if (bodyMd5 != null) {
            header.setAttribute(SQS_MESSAGE_BODY_MD5_ATTRIBUTE, bodyMd5);
        }
        final String attrsMd5 = message.getMD5OfMessageAttributes();
        if (attrsMd5 != null) {
            header.setAttribute(SQS_MESSAGE_ATTRIBUTE_MD5_ATTRIBUTE, attrsMd5);
        }
        // fall through
    case BASIC:
        header.setAttribute(SQS_MESSAGE_ID_ATTRIBUTE, message.getMessageId());
        header.setAttribute(SQS_QUEUE_NAME_PREFIX_ATTRIBUTE, queueNamePrefix);
        header.setAttribute(SQS_REGION_ATTRIBUTE, awsRegionLabel);
        break;
    case NONE:
        // empty block
        break;
    }
}