本文整理了Java中com.amazonaws.services.sqs.model.Message.getMessageAttributes()
方法的一些代码示例,展示了Message.getMessageAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getMessageAttributes()
方法的具体详情如下:
包路径:com.amazonaws.services.sqs.model.Message
类名称:Message
方法名:getMessageAttributes
[英]Each message attribute consists of a Name, Type, and Value. For more information, see Message Attribute Items in the Amazon SQS Developer Guide.
[中]每个消息属性由名称、类型和值组成。有关更多信息,请参阅《Amazon SQS开发人员指南》中的{$0$}。
代码示例来源: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
/**
* 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/aws-sdk-java
if (other.getMD5OfMessageAttributes() != null && other.getMD5OfMessageAttributes().equals(this.getMD5OfMessageAttributes()) == false)
return false;
if (other.getMessageAttributes() == null ^ this.getMessageAttributes() == null)
return false;
if (other.getMessageAttributes() != null && other.getMessageAttributes().equals(this.getMessageAttributes()) == false)
return false;
return true;
代码示例来源:origin: apache/nifi
for (final Map.Entry<String, MessageAttributeValue> entry : message.getMessageAttributes().entrySet()) {
attributes.put("sqs." + entry.getKey(), entry.getValue().getStringValue());
代码示例来源: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.getMD5OfMessageAttributes().equals(this.getMD5OfMessageAttributes()) == false)
return false;
if (other.getMessageAttributes() == null ^ this.getMessageAttributes() == null)
return false;
if (other.getMessageAttributes() != null
&& other.getMessageAttributes().equals(this.getMessageAttributes()) == false)
return false;
return true;
代码示例来源:origin: aws-amplify/aws-sdk-android
request.addParameter(prefix, StringUtils.fromString(mD5OfMessageAttributes));
if (_message.getMessageAttributes() != null) {
prefix = _prefix + "MessageAttribute";
java.util.Map<String, MessageAttributeValue> messageAttributes = _message
.getMessageAttributes();
int messageAttributesIndex = 1;
String messageAttributesPrefix = prefix + ".";
代码示例来源:origin: awslabs/amazon-sqs-java-messaging-lib
private void addMessageAttributes(com.amazonaws.services.sqs.model.Message sqsMessage) throws JMSException {
for (Entry<String, MessageAttributeValue> entry : sqsMessage.getMessageAttributes().entrySet()) {
properties.put(entry.getKey(), new JMSMessagePropertyValue(
entry.getValue().getStringValue(), entry.getValue().getDataType()));
}
}
代码示例来源:origin: payara/Cloud-Connectors
@OnSQSMessage
public void receiveMessage(Message message) {
System.out.println("Got message " + message.getBody());
Map<String,MessageAttributeValue> mattrs = message.getMessageAttributes();
for (String key : mattrs.keySet()) {
System.out.println("Got Message attribute " + key + "," + mattrs.get(key).getStringValue());
}
Map<String,String> attrs = message.getAttributes();
for (String key : attrs.keySet()) {
System.out.println("Got attribute " + key + "," + attrs.get(key));
}
}
}
代码示例来源:origin: spring-cloud/spring-cloud-aws
private static Map<String, Object> getMessageAttributesAsMessageHeaders(com.amazonaws.services.sqs.model.Message message) {
Map<String, Object> messageHeaders = new HashMap<>();
for (Map.Entry<String, MessageAttributeValue> messageAttribute : message.getMessageAttributes().entrySet()) {
if (MessageHeaders.CONTENT_TYPE.equals(messageAttribute.getKey())) {
messageHeaders.put(MessageHeaders.CONTENT_TYPE, MimeType.valueOf(messageAttribute.getValue().getStringValue()));
} else if (MessageHeaders.ID.equals(messageAttribute.getKey())) {
messageHeaders.put(MessageHeaders.ID, UUID.fromString(messageAttribute.getValue().getStringValue()));
} else if (MessageAttributeDataTypes.STRING.equals(messageAttribute.getValue().getDataType())) {
messageHeaders.put(messageAttribute.getKey(), messageAttribute.getValue().getStringValue());
} else if (messageAttribute.getValue().getDataType().startsWith(MessageAttributeDataTypes.NUMBER)) {
Object numberValue = getNumberValue(messageAttribute.getValue());
if (numberValue != null) {
messageHeaders.put(messageAttribute.getKey(), numberValue);
}
} else if (MessageAttributeDataTypes.BINARY.equals(messageAttribute.getValue().getDataType())) {
messageHeaders.put(messageAttribute.getKey(), messageAttribute.getValue().getBinaryValue());
}
}
return messageHeaders;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-aws-messaging
private static Map<String, Object> getMessageAttributesAsMessageHeaders(com.amazonaws.services.sqs.model.Message message) {
Map<String, Object> messageHeaders = new HashMap<>();
for (Map.Entry<String, MessageAttributeValue> messageAttribute : message.getMessageAttributes().entrySet()) {
if (MessageHeaders.CONTENT_TYPE.equals(messageAttribute.getKey())) {
messageHeaders.put(MessageHeaders.CONTENT_TYPE, MimeType.valueOf(messageAttribute.getValue().getStringValue()));
} else if (MessageHeaders.ID.equals(messageAttribute.getKey())) {
messageHeaders.put(MessageHeaders.ID, UUID.fromString(messageAttribute.getValue().getStringValue()));
} else if (MessageAttributeDataTypes.STRING.equals(messageAttribute.getValue().getDataType())) {
messageHeaders.put(messageAttribute.getKey(), messageAttribute.getValue().getStringValue());
} else if (messageAttribute.getValue().getDataType().startsWith(MessageAttributeDataTypes.NUMBER)) {
Object numberValue = getNumberValue(messageAttribute.getValue());
if (numberValue != null) {
messageHeaders.put(messageAttribute.getKey(), numberValue);
}
} else if (MessageAttributeDataTypes.BINARY.equals(messageAttribute.getValue().getDataType())) {
messageHeaders.put(messageAttribute.getKey(), messageAttribute.getValue().getBinaryValue());
}
}
return messageHeaders;
}
代码示例来源: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.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: com.amazonaws/aws-android-sdk-sqs
/**
* 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: com.amazonaws/aws-java-sdk-sqs
/**
* 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: com.amazonaws/aws-android-sdk-sqs
/**
* 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));
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!