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());
}
}
}
}
Aggregations