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 0129f47ad9..f803cfa78c 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 @@ -16,6 +16,7 @@ */ package org.apache.activemq.artemis.core.protocol.proton.converter.message; +import org.apache.activemq.artemis.core.message.impl.MessageInternal; import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.Symbol; import org.apache.qpid.proton.amqp.UnsignedByte; @@ -31,6 +32,7 @@ import org.apache.qpid.proton.amqp.messaging.MessageAnnotations; import org.apache.qpid.proton.amqp.messaging.Properties; import org.apache.qpid.proton.amqp.messaging.Section; import org.apache.qpid.proton.message.ProtonJMessage; +import org.jboss.logging.Logger; import org.proton.plug.exceptions.ActiveMQAMQPIllegalStateException; import javax.jms.BytesMessage; @@ -55,7 +57,7 @@ import java.util.Enumeration; import java.util.HashMap; public class JMSMappingOutboundTransformer extends OutboundTransformer { - + private static final Logger logger = Logger.getLogger(JMSMappingOutboundTransformer.class); public static final Symbol JMS_DEST_TYPE_MSG_ANNOTATION = Symbol.valueOf("x-opt-jms-dest"); public static final Symbol JMS_REPLY_TO_TYPE_MSG_ANNOTATION = Symbol.valueOf("x-opt-jms-reply-to"); @@ -140,9 +142,22 @@ public class JMSMappingOutboundTransformer extends OutboundTransformer { } if (body == null && msg instanceof org.apache.activemq.artemis.core.protocol.proton.converter.jms.ServerJMSMessage) { - Object s = ((org.apache.activemq.artemis.core.protocol.proton.converter.jms.ServerJMSMessage) msg).getInnerMessage().getBodyBuffer().readNullableSimpleString(); - if (s != null) { - body = new AmqpValue(s.toString()); + + MessageInternal internalMessage = ((org.apache.activemq.artemis.core.protocol.proton.converter.jms.ServerJMSMessage) msg).getInnerMessage(); + if (!internalMessage.containsProperty("AMQP_MESSAGE_FORMAT")) { + int readerIndex = internalMessage.getBodyBuffer().readerIndex(); + try { + Object s = internalMessage.getBodyBuffer().readNullableSimpleString(); + if (s != null) { + body = new AmqpValue(s.toString()); + } + } + catch (Throwable ignored) { + logger.debug("Exception ignored during conversion, should be ok!", ignored.getMessage(), ignored); + } + finally { + internalMessage.getBodyBuffer().readerIndex(readerIndex); + } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java index 5e5aebea7c..26cbde7534 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerMessageImpl.java @@ -288,9 +288,14 @@ public class ServerMessageImpl extends MessageImpl implements ServerMessage { @Override public String toString() { - return "ServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBufferDuplicate().capacity() + - ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) + - ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this); + try { + return "ServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", bodySize=" + this.getBodyBufferDuplicate().capacity() + + ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) + + ", durable=" + durable + ", address=" + getAddress() + ",properties=" + properties.toString() + "]@" + System.identityHashCode(this); + } + catch (Throwable e) { + return "ServerMessage[messageID=" + messageID + "]"; + } } private static String toDate(long timestamp) { diff --git a/tests/joram-tests/src/test/resources/provider.properties b/tests/joram-tests/src/test/resources/provider.properties index 1307a791a1..c845ef312d 100644 --- a/tests/joram-tests/src/test/resources/provider.properties +++ b/tests/joram-tests/src/test/resources/provider.properties @@ -20,9 +20,6 @@ ## jms.provider.admin.class=org.apache.activemq.artemis.jms.ActiveMQCoreAdmin -#jms.provider.admin.class = org.apache.activemq.artemis.api.jms.GenericAdmin -#jms.provider.admin.class = org.objectweb.jtests.providers.admin.JoramAdmin -#jms.provider.admin.class = org.objectweb.jtests.providers.admin.AshnaMQAdmin -#jms.provider.admin.class = org.objectweb.jtests.providers.admin.FioranoMQAdmin -#jms.provider.admin.class = org.objectweb.jtests.providers.admin.PramatiAdmin -#jms.provider.admin.class = org.objectweb.jtests.providers.admin.SwiftMQAdmin \ No newline at end of file + +# Uncomment this to use AMQP by default on tests +#jms.provider.admin.class=org.apache.activemq.artemis.amqpJMS.ActiveMQAMQPAdmin