Java Code Examples for com.amazonaws.services.sqs.model.MessageAttributeValue#getStringValue()
The following examples show how to use
com.amazonaws.services.sqs.model.MessageAttributeValue#getStringValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmazonSQSResponderClient.java From amazon-sqs-java-temporary-queues-client with Apache License 2.0 | 7 votes |
@Override public void sendResponseMessage(MessageContent request, MessageContent response) { MessageAttributeValue attribute = request.getMessageAttributes().get(AmazonSQSRequesterClient.RESPONSE_QUEUE_URL_ATTRIBUTE_NAME); if (attribute != null) { String replyQueueUrl = attribute.getStringValue(); try { SendMessageRequest responseRequest = response.toSendMessageRequest() .withQueueUrl(replyQueueUrl); sqs.sendMessage(responseRequest); } catch (QueueDoesNotExistException e) { // Stale request, ignore // TODO-RS: CW metric LOG.warn("Ignoring response to deleted response queue: " + replyQueueUrl); } } else { // TODO-RS: CW metric LOG.warn("Attempted to send response when none was requested"); } }
Example 2
Source File: AmazonSQSExtendedClient.java From amazon-sqs-java-extended-client-lib with Apache License 2.0 | 6 votes |
private int getMsgAttributesSize(Map<String, MessageAttributeValue> msgAttributes) { int totalMsgAttributesSize = 0; for (Entry<String, MessageAttributeValue> entry : msgAttributes.entrySet()) { totalMsgAttributesSize += getStringSizeInBytes(entry.getKey()); MessageAttributeValue entryVal = entry.getValue(); if (entryVal.getDataType() != null) { totalMsgAttributesSize += getStringSizeInBytes(entryVal.getDataType()); } String stringVal = entryVal.getStringValue(); if (stringVal != null) { totalMsgAttributesSize += getStringSizeInBytes(entryVal.getStringValue()); } ByteBuffer binaryVal = entryVal.getBinaryValue(); if (binaryVal != null) { totalMsgAttributesSize += binaryVal.array().length; } } return totalMsgAttributesSize; }
Example 3
Source File: SQSMessageConsumerPrefetch.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 4 votes |
/** * Convert the return SQS message into JMS message * @param message SQS message to convert * @return Converted JMS message * @throws JMSException */ protected javax.jms.Message convertToJMSMessage(Message message) throws JMSException { MessageAttributeValue messageTypeAttribute = message.getMessageAttributes().get( SQSMessage.JMS_SQS_MESSAGE_TYPE); javax.jms.Message jmsMessage = null; if (messageTypeAttribute == null) { jmsMessage = new SQSTextMessage(acknowledger, queueUrl, message); } else { String messageType = messageTypeAttribute.getStringValue(); if (SQSMessage.BYTE_MESSAGE_TYPE.equals(messageType)) { try { jmsMessage = new SQSBytesMessage(acknowledger, queueUrl, message); } catch (JMSException e) { LOG.warn("MessageReceiptHandle - " + message.getReceiptHandle() + "cannot be serialized to BytesMessage", e); throw e; } } else if (SQSMessage.OBJECT_MESSAGE_TYPE.equals(messageType)) { jmsMessage = new SQSObjectMessage(acknowledger, queueUrl, message); } else if (SQSMessage.TEXT_MESSAGE_TYPE.equals(messageType)) { jmsMessage = new SQSTextMessage(acknowledger, queueUrl, message); } else { throw new JMSException("Not a supported JMS message type"); } } jmsMessage.setJMSDestination(sqsDestination); MessageAttributeValue replyToQueueNameAttribute = message.getMessageAttributes().get( SQSMessage.JMS_SQS_REPLY_TO_QUEUE_NAME); MessageAttributeValue replyToQueueUrlAttribute = message.getMessageAttributes().get( SQSMessage.JMS_SQS_REPLY_TO_QUEUE_URL); if (replyToQueueNameAttribute != null && replyToQueueUrlAttribute != null) { String replyToQueueUrl = replyToQueueUrlAttribute.getStringValue(); String replyToQueueName = replyToQueueNameAttribute.getStringValue(); Destination replyToQueue = new SQSQueueDestination(replyToQueueName, replyToQueueUrl); jmsMessage.setJMSReplyTo(replyToQueue); } MessageAttributeValue correlationIdAttribute = message.getMessageAttributes().get( SQSMessage.JMS_SQS_CORRELATION_ID); if (correlationIdAttribute != null) { jmsMessage.setJMSCorrelationID(correlationIdAttribute.getStringValue()); } return jmsMessage; }