Map<String, MessageAttributeValue> propertyToMessageAttribute(SQSMessage message)
            throws JMSException {
        Map<String, MessageAttributeValue> messageAttributes = new HashMap<String, MessageAttributeValue>();
        Enumeration<String> propertyNames = message.getPropertyNames();

        while (propertyNames.hasMoreElements()) {
            String propertyName = propertyNames.nextElement();

            // This is generated from SQS message attribute "ApproximateReceiveCount"
            if (propertyName.equals(SQSMessagingClientConstants.JMSX_DELIVERY_COUNT)) {
                continue;
            }

            // This property will be used as DeduplicationId argument of SendMessage call
            // On receive it is mapped back to this JMS property
            if (propertyName.equals(SQSMessagingClientConstants.JMS_SQS_DEDUPLICATION_ID)) {
                continue;
            }

            // the JMSXGroupID and JMSXGroupSeq are always stored as message
            // properties, so they are not lost between send and receive
            // even though SQS Classic does not respect those values when returning messages
            // and SQS FIFO has a different understanding of message groups

            JMSMessagePropertyValue propertyObject = message.getJMSMessagePropertyValue(propertyName);
            MessageAttributeValue messageAttributeValue = new MessageAttributeValue();

            messageAttributeValue.setDataType(propertyObject.getType());
            messageAttributeValue.setStringValue(propertyObject.getStringMessageAttributeValue());

            messageAttributes.put(propertyName, messageAttributeValue);
        }
        return messageAttributes;
    }
Map < String , MessageAttributeValue > propertyToMessageAttribute ( SQSMessage message ) throws JMSException { Map < String , MessageAttributeValue > messageAttributes = new HashMap < String , MessageAttributeValue > ( ) ; Enumeration < String > propertyNames = message . getPropertyNames ( ) ; while ( propertyNames . hasMoreElements ( ) ) { String propertyName = propertyNames . nextElement ( ) ; if ( propertyName . equals ( SQSMessagingClientConstants . JMSX_DELIVERY_COUNT ) ) { continue ; } if ( propertyName . equals ( SQSMessagingClientConstants . JMS_SQS_DEDUPLICATION_ID ) ) { continue ; } JMSMessagePropertyValue propertyObject = message . getJMSMessagePropertyValue ( propertyName ) ; MessageAttributeValue messageAttributeValue = new MessageAttributeValue ( ) ; messageAttributeValue . setDataType ( propertyObject . getType ( ) ) ; messageAttributeValue . setStringValue ( propertyObject . getStringMessageAttributeValue ( ) ) ; messageAttributes . put ( propertyName , messageAttributeValue ) ; } return messageAttributes ; }
Not verified on the client side, but SQS Attribute names must be valid
letter or digit on the basic multilingual plane in addition to allowing
'_', '-' and '.'. No component of an attribute name may be empty, thus an
attribute name may neither start nor end in '.'. And it may not contain
"..".