com.amazonaws.services.sqs.model.Message.getBody()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.amazonaws.services.sqs.model.Message.getBody()方法的一些代码示例,展示了Message.getBody()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getBody()方法的具体详情如下:
包路径:com.amazonaws.services.sqs.model.Message
类名称:Message
方法名:getBody

Message.getBody介绍

[英]The message's contents (not URL-encoded).
[中]消息的内容(非URL编码)。

代码示例

代码示例来源:origin: apache/nifi

@Override
  public void process(final OutputStream out) throws IOException {
    out.write(message.getBody().getBytes(charset));
  }
});

代码示例来源:origin: aws/aws-sdk-java

/**
 * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
 * redacted from this string using a placeholder value.
 *
 * @return A string representation of this object.
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getMessageId() != null)
    sb.append("MessageId: ").append(getMessageId()).append(",");
  if (getReceiptHandle() != null)
    sb.append("ReceiptHandle: ").append(getReceiptHandle()).append(",");
  if (getMD5OfBody() != null)
    sb.append("MD5OfBody: ").append(getMD5OfBody()).append(",");
  if (getBody() != null)
    sb.append("Body: ").append(getBody()).append(",");
  if (getAttributes() != null)
    sb.append("Attributes: ").append(getAttributes()).append(",");
  if (getMD5OfMessageAttributes() != null)
    sb.append("MD5OfMessageAttributes: ").append(getMD5OfMessageAttributes()).append(",");
  if (getMessageAttributes() != null)
    sb.append("MessageAttributes: ").append(getMessageAttributes());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getMessageId() == null) ? 0 : getMessageId().hashCode());
  hashCode = prime * hashCode + ((getReceiptHandle() == null) ? 0 : getReceiptHandle().hashCode());
  hashCode = prime * hashCode + ((getMD5OfBody() == null) ? 0 : getMD5OfBody().hashCode());
  hashCode = prime * hashCode + ((getBody() == null) ? 0 : getBody().hashCode());
  hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode());
  hashCode = prime * hashCode + ((getMD5OfMessageAttributes() == null) ? 0 : getMD5OfMessageAttributes().hashCode());
  hashCode = prime * hashCode + ((getMessageAttributes() == null) ? 0 : getMessageAttributes().hashCode());
  return hashCode;
}

代码示例来源:origin: aws/aws-sdk-java

List<Message> messages = sqs.receiveMessage(new ReceiveMessageRequest(queueUrl)).getMessages();
for (Message message : messages) {
  String messageBody = message.getBody();
  if (!messageBody.startsWith("{")) {
    messageBody = new String(BinaryUtils.fromBase64(messageBody));

代码示例来源:origin: Netflix/conductor

@VisibleForTesting
List<Message> receiveMessages() {
  try {
    ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest()
        .withQueueUrl(queueURL)
        .withVisibilityTimeout(visibilityTimeoutInSeconds)
        .withMaxNumberOfMessages(batchSize);
    ReceiveMessageResult result = client.receiveMessage(receiveMessageRequest);
    List<Message> messages = result.getMessages().stream()
        .map(msg -> new Message(msg.getMessageId(), msg.getBody(), msg.getReceiptHandle()))
        .collect(Collectors.toList());
    Monitors.recordEventQueueMessagesProcessed(QUEUE_TYPE, this.queueName, messages.size());
    return messages;
  } catch (Exception e) {
    logger.error("Exception while getting messages from SQS", e);
    Monitors.recordObservableQMessageReceivedErrors(QUEUE_TYPE);
  }
  return new ArrayList<>();
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Throw an exception if the MD5 checksums included in the ReceiveMessageResult do not match the
 * client-side calculation on the received messages.
 */
private static void receiveMessageResultMd5Check(ReceiveMessageResult receiveMessageResult) {
  if (receiveMessageResult.getMessages() != null) {
    for (Message messageReceived : receiveMessageResult.getMessages()) {
      String messageBody = messageReceived.getBody();
      String bodyMd5Returned = messageReceived.getMD5OfBody();
      String clientSideBodyMd5 = calculateMessageBodyMd5(messageBody);
      if (!clientSideBodyMd5.equals(bodyMd5Returned)) {
        throw new AmazonClientException(String.format(MD5_MISMATCH_ERROR_MESSAGE, MESSAGE_BODY,
            clientSideBodyMd5, bodyMd5Returned));
      }
      Map<String, MessageAttributeValue> messageAttr = messageReceived.getMessageAttributes();
      if (messageAttr != null && !messageAttr.isEmpty()) {
        String attrMd5Returned = messageReceived.getMD5OfMessageAttributes();
        String clientSideAttrMd5 = calculateMessageAttributesMd5(messageAttr);
        if (!clientSideAttrMd5.equals(attrMd5Returned)) {
          throw new AmazonClientException(String.format(MD5_MISMATCH_ERROR_MESSAGE, MESSAGE_ATTRIBUTES,
              clientSideAttrMd5, attrMd5Returned));
        }
      }
    }
  }
}

代码示例来源:origin: apache/usergrid

final String originalBody = message.getBody();
  final JsonNode bodyNode = mapper.readTree( message.getBody() );
  logger.error( "failed to deserialize message: {}", message.getBody(), e );
  throw new RuntimeException( e );

代码示例来源:origin: aws/aws-sdk-java

if (other.getMD5OfBody() != null && other.getMD5OfBody().equals(this.getMD5OfBody()) == false)
  return false;
if (other.getBody() == null ^ this.getBody() == null)
  return false;
if (other.getBody() != null && other.getBody().equals(this.getBody()) == false)
  return false;
if (other.getAttributes() == null ^ this.getAttributes() == null)

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getMessageId() == null) ? 0 : getMessageId().hashCode());
  hashCode = prime * hashCode
      + ((getReceiptHandle() == null) ? 0 : getReceiptHandle().hashCode());
  hashCode = prime * hashCode + ((getMD5OfBody() == null) ? 0 : getMD5OfBody().hashCode());
  hashCode = prime * hashCode + ((getBody() == null) ? 0 : getBody().hashCode());
  hashCode = prime * hashCode + ((getAttributes() == null) ? 0 : getAttributes().hashCode());
  hashCode = prime
      * hashCode
      + ((getMD5OfMessageAttributes() == null) ? 0 : getMD5OfMessageAttributes()
          .hashCode());
  hashCode = prime * hashCode
      + ((getMessageAttributes() == null) ? 0 : getMessageAttributes().hashCode());
  return hashCode;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Returns a string representation of this object; useful for testing and
 * debugging.
 *
 * @return A string representation of this object.
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getMessageId() != null)
    sb.append("MessageId: " + getMessageId() + ",");
  if (getReceiptHandle() != null)
    sb.append("ReceiptHandle: " + getReceiptHandle() + ",");
  if (getMD5OfBody() != null)
    sb.append("MD5OfBody: " + getMD5OfBody() + ",");
  if (getBody() != null)
    sb.append("Body: " + getBody() + ",");
  if (getAttributes() != null)
    sb.append("Attributes: " + getAttributes() + ",");
  if (getMD5OfMessageAttributes() != null)
    sb.append("MD5OfMessageAttributes: " + getMD5OfMessageAttributes() + ",");
  if (getMessageAttributes() != null)
    sb.append("MessageAttributes: " + getMessageAttributes());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Throw an exception if the MD5 checksums included in the
 * ReceiveMessageResult do not match the client-side calculation on the
 * received messages.
 */
private static void receiveMessageResultMd5Check(ReceiveMessageResult receiveMessageResult) {
  if (receiveMessageResult.getMessages() != null) {
    for (Message messageReceived : receiveMessageResult.getMessages()) {
      String messageBody = messageReceived.getBody();
      String bodyMd5Returned = messageReceived.getMD5OfBody();
      String clientSideBodyMd5 = calculateMessageBodyMd5(messageBody);
      if (!clientSideBodyMd5.equals(bodyMd5Returned)) {
        throw new AmazonClientException(String.format(
            MD5_MISMATCH_ERROR_MESSAGE, MESSAGE_BODY,
            clientSideBodyMd5, bodyMd5Returned));
      }
      Map<String, MessageAttributeValue> messageAttr = messageReceived
          .getMessageAttributes();
      if (messageAttr != null && !messageAttr.isEmpty()) {
        String attrMd5Returned = messageReceived.getMD5OfMessageAttributes();
        String clientSideAttrMd5 = calculateMessageAttributesMd5(messageAttr);
        if (!clientSideAttrMd5.equals(attrMd5Returned)) {
          throw new AmazonClientException(String.format(
              MD5_MISMATCH_ERROR_MESSAGE, MESSAGE_ATTRIBUTES,
              clientSideAttrMd5, attrMd5Returned));
        }
      }
    }
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

&& other.getMD5OfBody().equals(this.getMD5OfBody()) == false)
  return false;
if (other.getBody() == null ^ this.getBody() == null)
  return false;
if (other.getBody() != null && other.getBody().equals(this.getBody()) == false)
  return false;
if (other.getAttributes() == null ^ this.getAttributes() == null)

代码示例来源:origin: com.amazonaws/amazon-sqs-java-messaging-lib

/**
 * Create new empty TextMessage to send.
 */
public SQSTextMessage() throws JMSException {
  super();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

request.addParameter(prefix, StringUtils.fromString(mD5OfBody));
if (_message.getBody() != null) {
  prefix = _prefix + "Body";
  String body = _message.getBody();
  request.addParameter(prefix, StringUtils.fromString(body));

代码示例来源:origin: org.apache.nifi/nifi-aws-processors

@Override
  public void process(final OutputStream out) throws IOException {
    out.write(message.getBody().getBytes(charset));
  }
});

代码示例来源:origin: io.zipkin.aws/zipkin-aws-junit

static Stream<? extends Span> decodeSpans(Message m) {
  byte[] bytes =
    m.getBody().charAt(0) == '['
      ? m.getBody().getBytes(Charset.forName("UTF-8"))
      : Base64.decode(m.getBody());
  if (bytes[0] == '[') {
   return SpanBytesDecoder.JSON_V2.decodeList(bytes).stream();
  }
  return SpanBytesDecoder.PROTO3.decodeList(bytes).stream();
 }
}

代码示例来源:origin: aws/aws-cloudtrail-processing-library

@Override
public CloudTrailSource getSource(Message sqsMessage) throws IOException{
  JsonNode s3MessageNode = mapper.readTree(sqsMessage.getBody());
  return getCloudTrailSource(sqsMessage, s3MessageNode);
}

代码示例来源:origin: com.hotels/shunting-yard-receiver-sqs

private ListenerEvent eventPayLoad(Message message) {
 try {
  return sqsDeserializer.unmarshal(message.getBody());
 } catch (Exception e) {
  throw new SerDeException("Unable to unmarshall event", e);
 }
}

代码示例来源:origin: spring-cloud/spring-cloud-aws

public static Message<String> createMessage(com.amazonaws.services.sqs.model.Message message, Map<String, Object> additionalHeaders) {
  HashMap<String, Object> messageHeaders = new HashMap<>();
  messageHeaders.put(MESSAGE_ID_MESSAGE_ATTRIBUTE_NAME, message.getMessageId());
  messageHeaders.put(RECEIPT_HANDLE_MESSAGE_ATTRIBUTE_NAME, message.getReceiptHandle());
  messageHeaders.putAll(additionalHeaders);
  messageHeaders.putAll(getAttributesAsMessageHeaders(message));
  messageHeaders.putAll(getMessageAttributesAsMessageHeaders(message));
  return new GenericMessage<>(message.getBody(), new SqsMessageHeaders(messageHeaders));
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-messaging

public static Message<String> createMessage(com.amazonaws.services.sqs.model.Message message, Map<String, Object> additionalHeaders) {
  HashMap<String, Object> messageHeaders = new HashMap<>();
  messageHeaders.put(MESSAGE_ID_MESSAGE_ATTRIBUTE_NAME, message.getMessageId());
  messageHeaders.put(RECEIPT_HANDLE_MESSAGE_ATTRIBUTE_NAME, message.getReceiptHandle());
  messageHeaders.putAll(additionalHeaders);
  messageHeaders.putAll(getAttributesAsMessageHeaders(message));
  messageHeaders.putAll(getMessageAttributesAsMessageHeaders(message));
  return new GenericMessage<>(message.getBody(), new SqsMessageHeaders(messageHeaders));
}

相关文章