Search in sources :

Example 26 with AMQPType

use of com.swiftmq.amqp.v100.types.AMQPType in project swiftmq-ce by iitsoftware.

the class JMSMappingInboundTransformer method transformMap.

protected void transformMap(Map map, MessageImpl jmsMessage, String prefix) throws Exception {
    for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
        boolean isJMSType = false;
        Map.Entry entry = (Map.Entry) iter.next();
        AMQPType key = (AMQPType) entry.getKey();
        AMQPDescribedConstructor constructor = key.getConstructor();
        int code = constructor != null ? constructor.getFormatCode() : key.getCode();
        String propName = null;
        if (AMQPTypeDecoder.isULong(code))
            propName = prefix + String.valueOf(((AMQPUnsignedLong) key).getValue());
        else if (AMQPTypeDecoder.isSymbol(code)) {
            if (prefix.equals(prefixMA) && ((AMQPSymbol) key).getValue().equals("x-opt-jms-type"))
                isJMSType = true;
            propName = prefix + nameTranslator.translate(((AMQPSymbol) key).getValue());
        }
        if (isJMSType) {
            AMQPType t = (AMQPType) entry.getValue();
            if (AMQPTypeDecoder.isString(t.getCode()))
                jmsMessage.setJMSType(((AMQPString) entry.getValue()).getValue());
            else
                jmsMessage.setStringProperty("JMS_TYPE_ERROR", "x-opt-jms-type must be of String value");
        } else if (propName != null) {
            try {
                jmsMessage.setObjectProperty(propName, Util.convertAMQPtoJMS((AMQPType) entry.getValue()));
            } catch (Exception e) {
                jmsMessage.setStringProperty(propName + "_ERROR", e.getMessage());
            }
        }
    }
}
Also used : AMQPException(com.swiftmq.amqp.v100.client.AMQPException) JMSException(javax.jms.JMSException) Iterator(java.util.Iterator) Map(java.util.Map)

Aggregations

IOException (java.io.IOException)20 List (java.util.List)14 ArrayList (java.util.ArrayList)13 Map (java.util.Map)6 Iterator (java.util.Iterator)5 AmqpValue (com.swiftmq.amqp.v100.generated.messaging.message_format.AmqpValue)4 Error (com.swiftmq.amqp.v100.generated.transport.definitions.Error)4 Fields (com.swiftmq.amqp.v100.generated.transport.definitions.Fields)4 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)4 Handle (com.swiftmq.amqp.v100.generated.transport.definitions.Handle)3 SequenceNo (com.swiftmq.amqp.v100.generated.transport.definitions.SequenceNo)3 AMQPType (com.swiftmq.amqp.v100.types.AMQPType)3 AMQPException (com.swiftmq.amqp.v100.client.AMQPException)2 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)2 Coordinator (com.swiftmq.amqp.v100.generated.transactions.coordination.Coordinator)2 Declared (com.swiftmq.amqp.v100.generated.transactions.coordination.Declared)2 Milliseconds (com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds)2 Seconds (com.swiftmq.amqp.v100.generated.transport.definitions.Seconds)2 TransferNumber (com.swiftmq.amqp.v100.generated.transport.definitions.TransferNumber)2 AMQPString (com.swiftmq.amqp.v100.types.AMQPString)2