Refine search
final MessageAttributeValue mav = new MessageAttributeValue(); mav.setDataType("String"); mav.setStringValue(context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue()); messageAttributes.put(descriptor.getName(), mav);
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStringValue() == null) ? 0 : getStringValue().hashCode()); hashCode = prime * hashCode + ((getBinaryValue() == null) ? 0 : getBinaryValue().hashCode()); hashCode = prime * hashCode + ((getStringListValues() == null) ? 0 : getStringListValues().hashCode()); hashCode = prime * hashCode + ((getBinaryListValues() == null) ? 0 : getBinaryListValues().hashCode()); hashCode = prime * hashCode + ((getDataType() == null) ? 0 : getDataType().hashCode()); return hashCode; }
private void sendMessage(String action, String user) { final Map<String, MessageAttributeValue> messageAttributes = new HashMap<>(); messageAttributes.put("id", new MessageAttributeValue().withDataType("String").withStringValue(user)); messageAttributes.put("action", new MessageAttributeValue().withDataType("String").withStringValue(action)); SendMessageRequest sendMessageRequest = new SendMessageRequest() .withQueueUrl(queueUrl) .withMessageBody("-") .withMessageDeduplicationId(user + action) .withMessageGroupId(user) .withMessageAttributes(messageAttributes); try { sqs.sendMessage(sendMessageRequest); } catch (AmazonServiceException ex) { serviceErrorMeter.mark(); logger.warn("sqs service error: ", ex); } catch (AmazonClientException ex) { clientErrorMeter.mark(); logger.warn("sqs client error: ", ex); } catch (Throwable t) { logger.warn("sqs unexpected error: ", t); } }
public MessageAttributeValue unmarshall(StaxUnmarshallerContext context) throws Exception { MessageAttributeValue messageAttributeValue = new MessageAttributeValue(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; messageAttributeValue.setStringValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; messageAttributeValue.setBinaryValue(ByteBufferStaxUnmarshaller.getInstance().unmarshall(context)); continue; messageAttributeValue.withStringListValues(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; messageAttributeValue.withBinaryListValues(ByteBufferStaxUnmarshaller.getInstance().unmarshall(context)); continue; messageAttributeValue.setDataType(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
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; }
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())); } }
@Override protected MessageAttributeValue buildMessageAttribute(String dataType, Object value) { MessageAttributeValue messageAttributeValue = new MessageAttributeValue() .withDataType(dataType); if (value instanceof ByteBuffer) { return messageAttributeValue.withBinaryValue((ByteBuffer) value); } else { return messageAttributeValue.withStringValue(value.toString()); } }
private MessageAttributeValue getBinaryMessageAttribute(ByteBuffer messageHeaderValue) { return new MessageAttributeValue().withDataType(MessageAttributeDataTypes.BINARY).withBinaryValue(messageHeaderValue); }
attributes.put("sqs." + entry.getKey(), entry.getValue().getStringValue());
/** * <p> * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see <a * href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">ASCII Printable Characters</a>. * </p> * * @param stringValue * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see <a * href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">ASCII Printable Characters</a>. * @return Returns a reference to this object so that method calls can be chained together. */ public MessageAttributeValue withStringValue(String stringValue) { setStringValue(stringValue); return this; }
/** * <p> * Amazon SQS supports the following logical data types: <code>String</code>, <code>Number</code>, and * <code>Binary</code>. For the <code>Number</code> data type, you must use <code>StringValue</code>. * </p> * <p> * You can also append custom labels. For more information, see <a * href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html" * >Amazon SQS Message Attributes</a> in the <i>Amazon Simple Queue Service Developer Guide</i>. * </p> * * @param dataType * Amazon SQS supports the following logical data types: <code>String</code>, <code>Number</code>, and * <code>Binary</code>. For the <code>Number</code> data type, you must use <code>StringValue</code>.</p> * <p> * You can also append custom labels. For more information, see <a href= * "http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html" * >Amazon SQS Message Attributes</a> in the <i>Amazon Simple Queue Service Developer Guide</i>. * @return Returns a reference to this object so that method calls can be chained together. */ public MessageAttributeValue withDataType(String dataType) { setDataType(dataType); return this; }
public MessageAttributeValue unmarshall(StaxUnmarshallerContext context) throws Exception { MessageAttributeValue messageAttributeValue = new MessageAttributeValue(); messageAttributeValue.setStringValue(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; messageAttributeValue.setBinaryValue(ByteBufferStaxUnmarshaller.getInstance() .unmarshall(context)); continue; messageAttributeValue.withStringListValues(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue; messageAttributeValue.withBinaryListValues(ByteBufferStaxUnmarshaller .getInstance().unmarshall(context)); continue; messageAttributeValue.setDataType(StringStaxUnmarshaller.getInstance() .unmarshall(context)); continue;
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; }
private static Object getNumberValue(MessageAttributeValue value) { String numberType = value.getDataType().substring(MessageAttributeDataTypes.NUMBER.length() + 1); try { Class<? extends Number> numberTypeClass = Class.forName(numberType).asSubclass(Number.class); return NumberUtils.parseNumber(value.getStringValue(), numberTypeClass); } catch (ClassNotFoundException e) { throw new MessagingException(String.format("Message attribute with value '%s' and data type '%s' could not be converted " + "into a Number because target class was not found.", value.getStringValue(), value.getDataType()), e); } }
@Override protected MessageAttributeValue buildMessageAttribute(String dataType, Object value) { MessageAttributeValue messageAttributeValue = new MessageAttributeValue() .withDataType(dataType); if (value instanceof ByteBuffer) { return messageAttributeValue.withBinaryValue((ByteBuffer) value); } else { return messageAttributeValue.withStringValue(value.toString()); } }
private MessageAttributeValue getBinaryMessageAttribute(ByteBuffer messageHeaderValue) { return new MessageAttributeValue().withDataType(MessageAttributeDataTypes.BINARY).withBinaryValue(messageHeaderValue); }
@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)); } } }
/** * <p> * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see <a * href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">ASCII Printable Characters</a>. * </p> * * @param stringValue * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see <a * href="http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">ASCII Printable Characters</a>. * @return Returns a reference to this object so that method calls can be chained together. */ public MessageAttributeValue withStringValue(String stringValue) { setStringValue(stringValue); return this; }
/** * <p> * Amazon SQS supports the following logical data types: <code>String</code>, <code>Number</code>, and * <code>Binary</code>. For the <code>Number</code> data type, you must use <code>StringValue</code>. * </p> * <p> * You can also append custom labels. For more information, see <a * href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html" * >Amazon SQS Message Attributes</a> in the <i>Amazon Simple Queue Service Developer Guide</i>. * </p> * * @param dataType * Amazon SQS supports the following logical data types: <code>String</code>, <code>Number</code>, and * <code>Binary</code>. For the <code>Number</code> data type, you must use <code>StringValue</code>.</p> * <p> * You can also append custom labels. For more information, see <a href= * "http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html" * >Amazon SQS Message Attributes</a> in the <i>Amazon Simple Queue Service Developer Guide</i>. * @return Returns a reference to this object so that method calls can be chained together. */ public MessageAttributeValue withDataType(String dataType) { setDataType(dataType); return this; }
return false; MessageAttributeValue other = (MessageAttributeValue) obj; if (other.getStringValue() == null ^ this.getStringValue() == null) return false; if (other.getStringValue() != null && other.getStringValue().equals(this.getStringValue()) == false) return false; if (other.getBinaryValue() == null ^ this.getBinaryValue() == null) return false; if (other.getBinaryValue() != null && other.getBinaryValue().equals(this.getBinaryValue()) == false) return false; if (other.getStringListValues() == null ^ this.getStringListValues() == null) return false; if (other.getStringListValues() != null && other.getStringListValues().equals(this.getStringListValues()) == false) return false; if (other.getBinaryListValues() == null ^ this.getBinaryListValues() == null) return false; if (other.getBinaryListValues() != null && other.getBinaryListValues().equals(this.getBinaryListValues()) == false) return false; if (other.getDataType() == null ^ this.getDataType() == null) return false; if (other.getDataType() != null && other.getDataType().equals(this.getDataType()) == false) return false; return true;