From 688eac50ea7f73eb366eced72753073cdd3535dc Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Tue, 12 Jul 2016 18:18:26 -0400 Subject: [PATCH] ARTEMIS-629 Preserve the correlation ID type during conversions When converted to a core message type the original type of the CorrelationId in the AMQP message is lost, we must encode the type to prevent the loss of the original type as this value is meant to be immutable. --- .../proton/converter/message/InboundTransformer.java | 2 +- .../converter/message/JMSMappingOutboundTransformer.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/InboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/InboundTransformer.java index 71f75c4685..9560ac1c0e 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/InboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/InboundTransformer.java @@ -215,7 +215,7 @@ public abstract class InboundTransformer { jms.setJMSReplyTo(vendor.createDestination(properties.getReplyTo())); } if (properties.getCorrelationId() != null) { - jms.setJMSCorrelationID(properties.getCorrelationId().toString()); + jms.setJMSCorrelationID(AMQPMessageIdHelper.INSTANCE.toBaseMessageIdString(properties.getCorrelationId())); } if (properties.getContentType() != null) { jms.setStringProperty(prefixVendor + "ContentType", properties.getContentType().toString()); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java index 46dc2695ae..a6ccfa9827 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/proton/converter/message/JMSMappingOutboundTransformer.java @@ -176,7 +176,14 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { maMap.put(LEGACY_JMS_REPLY_TO_TYPE_MSG_ANNOTATION, destinationAttributes(msg.getJMSReplyTo())); } if (msg.getJMSCorrelationID() != null) { - props.setCorrelationId(msg.getJMSCorrelationID()); + String correlationId = msg.getJMSCorrelationID(); + + try { + props.setCorrelationId(AMQPMessageIdHelper.INSTANCE.toIdObject(correlationId)); + } + catch (ActiveMQAMQPIllegalStateException e) { + props.setCorrelationId(correlationId); + } } if (msg.getJMSExpiration() != 0) { long ttl = msg.getJMSExpiration() - System.currentTimeMillis();