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

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

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

Message.getMessageId介绍

[英]A unique identifier for the message. Message IDs are considered unique across all AWS accounts for an extended period of time.
[中]消息的唯一标识符。在很长一段时间内,所有AWS帐户中的消息ID都被认为是唯一的。

代码示例

代码示例来源: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: 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: apache/usergrid

LegacyQueueMessage queueMessage = new LegacyQueueMessage( message.getMessageId(), message.getReceiptHandle(), payload,
  message.getAttributes().get( "type" ) );
queueMessage.setStringBody( originalBody );

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

return false;
Message other = (Message) obj;
if (other.getMessageId() == null ^ this.getMessageId() == null)
  return false;
if (other.getMessageId() != null && other.getMessageId().equals(this.getMessageId()) == false)
  return false;
if (other.getReceiptHandle() == null ^ this.getReceiptHandle() == null)

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

attributes.put("sqs.message.id", message.getMessageId());
attributes.put("sqs.receipt.handle", message.getReceiptHandle());
for (final Message message : messages) {
  final DeleteMessageBatchRequestEntry entry = new DeleteMessageBatchRequestEntry();
  entry.setId(message.getMessageId());
  entry.setReceiptHandle(message.getReceiptHandle());
  deleteRequestEntries.add(entry);

代码示例来源: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

Message other = (Message) obj;
if (other.getMessageId() == null ^ this.getMessageId() == null)
  return false;
if (other.getMessageId() != null
    && other.getMessageId().equals(this.getMessageId()) == false)
  return false;
if (other.getReceiptHandle() == null ^ this.getReceiptHandle() == null)

代码示例来源:origin: org.symphonyoss.s2.fugue/aws-fugue

@Override
public String getMessageId()
{
 return message_.getMessageId();
}

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

public void marshall(Message _message, Request<?> request, String _prefix) {
  String prefix;
  if (_message.getMessageId() != null) {
    prefix = _prefix + "MessageId";
    String messageId = _message.getMessageId();
    request.addParameter(prefix, StringUtils.fromString(messageId));

代码示例来源:origin: skyscreamer/nevado

@Override
public String getMessageId() {
  return _message.getMessageId();
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-amazon-web-services

@Override
public byte[] getCurrentRecordId() throws NoSuchElementException {
 if (current == null) {
  throw new NoSuchElementException();
 }
 return current.getMessageId().getBytes(StandardCharsets.UTF_8);
}

代码示例来源:origin: awslabs/aws-serverless-sqs-event-source

private SQSMessageResult processMessage(final Message message) {
    try {
      T body = deserializer.deserialize(message);
      delegate.accept(body);
      return new SQSMessageResult(message.getMessageId(), SQSMessageResult.Status.SUCCESS);
    } catch (RetryMessageException e) {
      log.info("Retrying message {}", message, e);
      return new SQSMessageResult(message.getMessageId(), SQSMessageResult.Status.RETRY, e.getRetryDelayInSeconds());
    } catch (Exception e) {
      log.error("Unhandled exception while processing message {}", message, e);
      return new SQSMessageResult(message.getMessageId(), SQSMessageResult.Status.ERROR);
    }
  }
}

代码示例来源: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));
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-sqs

@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: com.amazonaws/aws-android-sdk-sqs

@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: Comcast/cmb

public CQSMessage(Message message) {
  
  this.messageId = message.getMessageId();
  this.receiptHandle = message.getReceiptHandle();
  this.body = message.getBody();
  this.mD5OfBody = message.getMD5OfBody();
  
  this.messageAttributes = new HashMap<String, CQSMessageAttribute>();
  
  for (String messageAttributeName : message.getMessageAttributes().keySet()) {
    MessageAttributeValue messageAttributeValue = message.getMessageAttributes().get(messageAttributeName);
    CQSMessageAttribute ma = new CQSMessageAttribute(messageAttributeValue.getStringValue(), messageAttributeValue.getDataType());
    this.messageAttributes.put(messageAttributeName, ma);
  }
  
  this.md5OfMessageAttributes = message.getMD5OfMessageAttributes();
}

代码示例来源:origin: com.netflix.spinnaker.echo/echo-pubsub-aws

@Override
public void ack() {
 // Delete from queue
 try {
  amazonSQS.deleteMessage(queueUrl, message.getReceiptHandle());
  registry.counter(getProcessedMetricId(subscriptionName)).increment();
 } catch (ReceiptHandleIsInvalidException e) {
  log.warn(
   "Error deleting message: {}, queue: {}, reason: {} (receiptHandle: {})",
   message.getMessageId(),
   queueUrl,
   e.getMessage(),
   message.getReceiptHandle()
  );
 }
}

相关文章