Repository: activemq-artemis Updated Branches: refs/heads/2.6.x 024db5bd3 -> 292566e39
ARTEMIS-2139 Reverting ARTEMIS-2023 for older clients prefixes. Revert "ARTEMIS-2023 Avoiding boolean on every message for 1x and tests" I'm reverting this into 2.6.x, however keeping it for master. This reverts commit 685211434a84a7a6ca2a65b8d0c187740743cb0b. (However it's keeping the test changes) Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/292566e3 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/292566e3 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/292566e3 Branch: refs/heads/2.6.x Commit: 292566e3906c510cfa055e5adaafec922af54ef7 Parents: 024db5b Author: Clebert Suconic <[email protected]> Authored: Mon Oct 22 11:49:17 2018 -0400 Committer: Clebert Suconic <[email protected]> Committed: Mon Oct 22 12:23:47 2018 -0400 ---------------------------------------------------------------------- .../artemis/jms/client/ActiveMQMapMessage.java | 2 +- .../artemis/jms/client/ActiveMQMessage.java | 57 ++++--- .../jms/client/ActiveMQMessageConsumer.java | 6 +- .../jms/client/ActiveMQQueueBrowser.java | 7 +- .../artemis/jms/client/ActiveMQSession.java | 70 ++------ .../jms/client/ActiveMQStreamMessage.java | 2 +- .../jms/client/JMSMessageListenerWrapper.java | 13 +- .../ActiveMQBytesCompatibleMessage.java | 57 ------- .../compatible1X/ActiveMQCompatibleMessage.java | 159 ------------------- .../ActiveMQMapCompatibleMessage.java | 58 ------- .../ActiveMQObjectCompatibleMessage.java | 61 ------- .../ActiveMQStreamCompatibleMessage.java | 59 ------- .../ActiveMQTextCompabileMessage.java | 50 ------ .../ra/inflow/ActiveMQMessageHandler.java | 13 +- 14 files changed, 69 insertions(+), 545 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java index e0249bf..2959737 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java @@ -36,7 +36,7 @@ import static org.apache.activemq.artemis.reader.MapMessageUtil.writeBodyMap; /** * ActiveMQ Artemis implementation of a JMS MapMessage. */ -public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage { +public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage { // Constants ----------------------------------------------------- public static final byte TYPE = Message.MAP_TYPE; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java index a3360ef..ff7da00 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java @@ -197,7 +197,7 @@ public class ActiveMQMessage implements javax.jms.Message { private String msgID; // Cache it - protected Destination replyTo; + private Destination replyTo; // Cache it private String jmsCorrelationID; @@ -209,6 +209,8 @@ public class ActiveMQMessage implements javax.jms.Message { private boolean clientAck; + private boolean enable1xPrefixes; + private long jmsDeliveryTime; // Constructors -------------------------------------------------- @@ -364,11 +366,23 @@ public class ActiveMQMessage implements javax.jms.Message { @Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { - - SimpleString repl = MessageUtil.getJMSReplyTo(message); - - if (repl != null) { - replyTo = ActiveMQDestination.fromPrefixedName(repl.toString()); + SimpleString address = MessageUtil.getJMSReplyTo(message); + if (address != null) { + String name = address.toString(); + + // swap the old prefixes for the new ones so the proper destination type gets created + if (enable1xPrefixes) { + if (address.startsWith(OLD_QUEUE_QUALIFIED_PREFIX)) { + name = address.subSeq(OLD_QUEUE_QUALIFIED_PREFIX.length(), address.length()).toString(); + } else if (address.startsWith(OLD_TEMP_QUEUE_QUALIFED_PREFIX)) { + name = address.subSeq(OLD_TEMP_QUEUE_QUALIFED_PREFIX.length(), address.length()).toString(); + } else if (address.startsWith(OLD_TOPIC_QUALIFIED_PREFIX)) { + name = address.subSeq(OLD_TOPIC_QUALIFIED_PREFIX.length(), address.length()).toString(); + } else if (address.startsWith(OLD_TEMP_TOPIC_QUALIFED_PREFIX)) { + name = address.subSeq(OLD_TEMP_TOPIC_QUALIFED_PREFIX.length(), address.length()).toString(); + } + } + replyTo = ActiveMQDestination.fromPrefixedName(address.toString(), name); } } return replyTo; @@ -403,20 +417,23 @@ public class ActiveMQMessage implements javax.jms.Message { } } - protected SimpleString checkPrefix(SimpleString address) { - return address; - } - - protected SimpleString checkPrefixStr(SimpleString address) { - return address; - } - - @Override public Destination getJMSDestination() throws JMSException { if (dest == null) { SimpleString address = message.getAddressSimpleString(); - SimpleString changedAddress = checkPrefix(address); + SimpleString name = address; + + if (address != null & enable1xPrefixes) { + if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX)) { + name = address.subSeq(PacketImpl.OLD_QUEUE_PREFIX.length(), address.length()); + } else if (address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX)) { + name = address.subSeq(PacketImpl.OLD_TEMP_QUEUE_PREFIX.length(), address.length()); + } else if (address.startsWith(PacketImpl.OLD_TOPIC_PREFIX)) { + name = address.subSeq(PacketImpl.OLD_TOPIC_PREFIX.length(), address.length()); + } else if (address.startsWith(PacketImpl.OLD_TEMP_TOPIC_PREFIX)) { + name = address.subSeq(PacketImpl.OLD_TEMP_TOPIC_PREFIX.length(), address.length()); + } + } if (address == null) { dest = null; @@ -428,8 +445,8 @@ public class ActiveMQMessage implements javax.jms.Message { dest = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address.toString()); } - if (changedAddress != null) { - ((ActiveMQDestination) dest).setName(changedAddress.toString()); + if (name != null) { + ((ActiveMQDestination) dest).setName(name.toString()); } } @@ -886,6 +903,10 @@ public class ActiveMQMessage implements javax.jms.Message { } } + public void setEnable1xPrefixes(boolean enable1xPrefixes) { + this.enable1xPrefixes = enable1xPrefixes; + } + @Override public String toString() { StringBuffer sb = new StringBuffer("ActiveMQMessage["); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java index dac8e57..8fabe8b 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java @@ -36,7 +36,6 @@ import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; /** * ActiveMQ Artemis implementation of a JMS MessageConsumer. @@ -219,11 +218,10 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr boolean needSession = ackMode == Session.CLIENT_ACKNOWLEDGE || ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE || coreMessage.getType() == ActiveMQObjectMessage.TYPE; + jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options); if (session.isEnable1xPrefixes()) { - jmsMsg = ActiveMQCompatibleMessage.createMessage(coreMessage, needSession ? coreSession : null, options); - } else { - jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options); + jmsMsg.setEnable1xPrefixes(true); } try { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java index 810166c..716d044 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java @@ -27,7 +27,6 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; import org.apache.activemq.artemis.utils.SelectorTranslator; /** @@ -142,10 +141,10 @@ public final class ActiveMQQueueBrowser implements QueueBrowser { if (hasMoreElements()) { ClientMessage next = current; current = null; + msg = ActiveMQMessage.createMessage(next, session, options); + if (enable1xPrefixes) { - msg = ActiveMQCompatibleMessage.createMessage(next, session, options); - } else { - msg = ActiveMQMessage.createMessage(next, session, options); + msg.setEnable1xPrefixes(true); } try { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java index 95d3608..528310f 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java @@ -62,12 +62,6 @@ import org.apache.activemq.artemis.api.core.client.ClientSession.AddressQuery; import org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery; import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQBytesCompatibleMessage; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQMapCompatibleMessage; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQObjectCompatibleMessage; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQStreamCompatibleMessage; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQTextCompabileMessage; import org.apache.activemq.artemis.selector.filter.FilterException; import org.apache.activemq.artemis.selector.impl.SelectorParser; import org.apache.activemq.artemis.utils.SelectorTranslator; @@ -150,12 +144,8 @@ public class ActiveMQSession implements QueueSession, TopicSession { public BytesMessage createBytesMessage() throws JMSException { checkClosed(); - ActiveMQBytesMessage message; - if (enable1xPrefixes) { - message = new ActiveMQBytesCompatibleMessage(session); - } else { - message = new ActiveMQBytesMessage(session); - } + ActiveMQBytesMessage message = new ActiveMQBytesMessage(session); + message.setEnable1xPrefixes(enable1xPrefixes); return message; } @@ -163,12 +153,8 @@ public class ActiveMQSession implements QueueSession, TopicSession { public MapMessage createMapMessage() throws JMSException { checkClosed(); - ActiveMQMapMessage message; - if (enable1xPrefixes) { - message = new ActiveMQMapCompatibleMessage(session); - } else { - message = new ActiveMQMapMessage(session); - } + ActiveMQMapMessage message = new ActiveMQMapMessage(session); + message.setEnable1xPrefixes(enable1xPrefixes); return message; } @@ -176,12 +162,8 @@ public class ActiveMQSession implements QueueSession, TopicSession { public Message createMessage() throws JMSException { checkClosed(); - ActiveMQMessage message; - if (enable1xPrefixes) { - message = new ActiveMQCompatibleMessage(session); - } else { - message = new ActiveMQMessage(session); - } + ActiveMQMessage message = new ActiveMQMessage(session); + message.setEnable1xPrefixes(enable1xPrefixes); return message; } @@ -189,12 +171,8 @@ public class ActiveMQSession implements QueueSession, TopicSession { public ObjectMessage createObjectMessage() throws JMSException { checkClosed(); - ActiveMQObjectMessage message; - if (enable1xPrefixes) { - message = new ActiveMQObjectCompatibleMessage(session, options); - } else { - message = new ActiveMQObjectMessage(session, options); - } + ActiveMQObjectMessage message = new ActiveMQObjectMessage(session, options); + message.setEnable1xPrefixes(enable1xPrefixes); return message; } @@ -202,13 +180,9 @@ public class ActiveMQSession implements QueueSession, TopicSession { public ObjectMessage createObjectMessage(final Serializable object) throws JMSException { checkClosed(); - ActiveMQObjectMessage msg; - if (enable1xPrefixes) { - msg = new ActiveMQObjectCompatibleMessage(session, options); - } else { - msg = new ActiveMQObjectMessage(session, options); - } + ActiveMQObjectMessage msg = new ActiveMQObjectMessage(session, options); msg.setObject(object); + msg.setEnable1xPrefixes(enable1xPrefixes); return msg; } @@ -217,12 +191,8 @@ public class ActiveMQSession implements QueueSession, TopicSession { public StreamMessage createStreamMessage() throws JMSException { checkClosed(); - ActiveMQStreamMessage message; - if (enable1xPrefixes) { - message = new ActiveMQStreamMessage(session); - } else { - message = new ActiveMQStreamCompatibleMessage(session); - } + ActiveMQStreamMessage message = new ActiveMQStreamMessage(session); + message.setEnable1xPrefixes(enable1xPrefixes); return message; } @@ -230,13 +200,9 @@ public class ActiveMQSession implements QueueSession, TopicSession { public TextMessage createTextMessage() throws JMSException { checkClosed(); - ActiveMQTextMessage msg; - if (enable1xPrefixes) { - msg = new ActiveMQTextCompabileMessage(session); - } else { - msg = new ActiveMQTextMessage(session); - } + ActiveMQTextMessage msg = new ActiveMQTextMessage(session); msg.setText(null); + msg.setEnable1xPrefixes(enable1xPrefixes); return msg; } @@ -245,13 +211,9 @@ public class ActiveMQSession implements QueueSession, TopicSession { public TextMessage createTextMessage(final String text) throws JMSException { checkClosed(); - ActiveMQTextMessage msg; - if (enable1xPrefixes) { - msg = new ActiveMQTextCompabileMessage(session); - } else { - msg = new ActiveMQTextMessage(session); - } + ActiveMQTextMessage msg = new ActiveMQTextMessage(session); msg.setText(text); + msg.setEnable1xPrefixes(enable1xPrefixes); return msg; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java index 6904df4..1c70c5b 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java @@ -44,7 +44,7 @@ import static org.apache.activemq.artemis.reader.StreamMessageUtil.streamReadStr /** * ActiveMQ Artemis implementation of a JMS StreamMessage. */ -public class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMessage { +public final class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMessage { public static final byte TYPE = Message.STREAM_TYPE; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java index f24e90d..0d2420b 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java @@ -25,7 +25,6 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; public class JMSMessageListenerWrapper implements MessageHandler { @@ -73,13 +72,7 @@ public class JMSMessageListenerWrapper implements MessageHandler { */ @Override public void onMessage(final ClientMessage message) { - ActiveMQMessage msg; - - if (session.isEnable1xPrefixes()) { - msg = ActiveMQCompatibleMessage.createMessage(message, session.getCoreSession(), options); - } else { - msg = ActiveMQMessage.createMessage(message, session.getCoreSession(), options); - } + ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session.getCoreSession(), options); if (individualACK) { msg.setIndividualAcknowledge(); @@ -89,6 +82,10 @@ public class JMSMessageListenerWrapper implements MessageHandler { msg.setClientAcknowledge(); } + if (session.isEnable1xPrefixes()) { + msg.setEnable1xPrefixes(true); + } + try { msg.doBeforeReceive(); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java deleted file mode 100644 index 626b5a5..0000000 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.activemq.artemis.jms.client.compatible1X; - -import javax.jms.BytesMessage; -import javax.jms.Destination; -import javax.jms.JMSException; - -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage; - -public class ActiveMQBytesCompatibleMessage extends ActiveMQBytesMessage { - - @Override - protected SimpleString checkPrefix(SimpleString address) { - return ActiveMQCompatibleMessage.checkPrefix1X(address); - } - - - @Override - public Destination getJMSReplyTo() throws JMSException { - if (replyTo == null) { - replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); - } - return replyTo; - } - - - public ActiveMQBytesCompatibleMessage(ClientSession session) { - super(session); - } - - protected ActiveMQBytesCompatibleMessage(ClientMessage message, ClientSession session) { - super(message, session); - } - - public ActiveMQBytesCompatibleMessage(BytesMessage foreign, ClientSession session) throws JMSException { - super(foreign, session); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java deleted file mode 100644 index 1b21cbf..0000000 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.activemq.artemis.jms.client.compatible1X; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.JMSRuntimeException; -import javax.jms.Message; - -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; -import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage; -import org.apache.activemq.artemis.jms.client.ActiveMQDestination; -import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; -import org.apache.activemq.artemis.jms.client.ActiveMQMessage; -import org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage; -import org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage; -import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; -import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.reader.MessageUtil; - -public class ActiveMQCompatibleMessage extends ActiveMQMessage { - - public ActiveMQCompatibleMessage(byte type, ClientSession session) { - super(type, session); - } - - public ActiveMQCompatibleMessage(ClientSession session) { - super(session); - } - - public ActiveMQCompatibleMessage(ClientMessage message, ClientSession session) { - super(message, session); - } - - public ActiveMQCompatibleMessage(Message foreign, ClientSession session) throws JMSException { - super(foreign, session); - } - - public ActiveMQCompatibleMessage() { - } - - public ActiveMQCompatibleMessage(Message foreign, byte type, ClientSession session) throws JMSException { - super(foreign, type, session); - } - - @Override - public Destination getJMSReplyTo() throws JMSException { - if (replyTo == null) { - replyTo = findCompatibleReplyTo(message); - } - return replyTo; - } - - public static Destination findCompatibleReplyTo(ClientMessage message) { - SimpleString address = MessageUtil.getJMSReplyTo(message); - if (address != null) { - String name = address.toString(); - - // swap the old prefixes for the new ones so the proper destination type gets created - if (address.startsWith(OLD_QUEUE_QUALIFIED_PREFIX)) { - name = address.subSeq(OLD_QUEUE_QUALIFIED_PREFIX.length(), address.length()).toString(); - } else if (address.startsWith(OLD_TEMP_QUEUE_QUALIFED_PREFIX)) { - name = address.subSeq(OLD_TEMP_QUEUE_QUALIFED_PREFIX.length(), address.length()).toString(); - } else if (address.startsWith(OLD_TOPIC_QUALIFIED_PREFIX)) { - name = address.subSeq(OLD_TOPIC_QUALIFIED_PREFIX.length(), address.length()).toString(); - } else if (address.startsWith(OLD_TEMP_TOPIC_QUALIFED_PREFIX)) { - name = address.subSeq(OLD_TEMP_TOPIC_QUALIFED_PREFIX.length(), address.length()).toString(); - } - return ActiveMQDestination.fromPrefixedName(address.toString(), name); - } - - return null; - } - - @Override - public SimpleString checkPrefix(SimpleString address) { - return checkPrefix1X(address); - } - - protected static SimpleString checkPrefix1X(SimpleString address) { - if (address != null) { - if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX)) { - return address.subSeq(PacketImpl.OLD_QUEUE_PREFIX.length(), address.length()); - } else if (address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX)) { - return address.subSeq(PacketImpl.OLD_TEMP_QUEUE_PREFIX.length(), address.length()); - } else if (address.startsWith(PacketImpl.OLD_TOPIC_PREFIX)) { - return address.subSeq(PacketImpl.OLD_TOPIC_PREFIX.length(), address.length()); - } else if (address.startsWith(PacketImpl.OLD_TEMP_TOPIC_PREFIX)) { - return address.subSeq(PacketImpl.OLD_TEMP_TOPIC_PREFIX.length(), address.length()); - } - } - - return null; - } - - public static ActiveMQMessage createMessage(final ClientMessage message, - final ClientSession session, - final ConnectionFactoryOptions options) { - int type = message.getType(); - - ActiveMQMessage msg; - - switch (type) { - case ActiveMQMessage.TYPE: // 0 - { - msg = new ActiveMQCompatibleMessage(message, session); - break; - } - case ActiveMQBytesMessage.TYPE: // 4 - { - msg = new ActiveMQBytesCompatibleMessage(message, session); - break; - } - case ActiveMQMapMessage.TYPE: // 5 - { - msg = new ActiveMQMapCompatibleMessage(message, session); - break; - } - case ActiveMQObjectMessage.TYPE: { - msg = new ActiveMQObjectCompatibleMessage(message, session, options); - break; - } - case ActiveMQStreamMessage.TYPE: // 6 - { - msg = new ActiveMQStreamCompatibleMessage(message, session); - break; - } - case ActiveMQTextMessage.TYPE: // 3 - { - msg = new ActiveMQTextCompabileMessage(message, session); - break; - } - default: { - throw new JMSRuntimeException("Invalid message type " + type); - } - } - - return msg; - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java deleted file mode 100644 index 2d6e576..0000000 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.activemq.artemis.jms.client.compatible1X; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MapMessage; - -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; - -public class ActiveMQMapCompatibleMessage extends ActiveMQMapMessage { - - @Override - protected SimpleString checkPrefix(SimpleString address) { - return ActiveMQCompatibleMessage.checkPrefix1X(address); - } - - @Override - public Destination getJMSReplyTo() throws JMSException { - if (replyTo == null) { - replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); - } - return replyTo; - } - - public ActiveMQMapCompatibleMessage(ClientSession session) { - super(session); - } - - public ActiveMQMapCompatibleMessage(ClientMessage message, ClientSession session) { - super(message, session); - } - - public ActiveMQMapCompatibleMessage() { - } - - public ActiveMQMapCompatibleMessage(MapMessage foreign, ClientSession session) throws JMSException { - super(foreign, session); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java deleted file mode 100644 index 13a9d7d..0000000 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.activemq.artemis.jms.client.compatible1X; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.ObjectMessage; - -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage; -import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; - -public class ActiveMQObjectCompatibleMessage extends ActiveMQObjectMessage { - - @Override - protected SimpleString checkPrefix(SimpleString address) { - return ActiveMQCompatibleMessage.checkPrefix1X(address); - } - - - @Override - public Destination getJMSReplyTo() throws JMSException { - if (replyTo == null) { - replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); - } - return replyTo; - } - - public ActiveMQObjectCompatibleMessage(ClientSession session, ConnectionFactoryOptions options) { - super(session, options); - } - - public ActiveMQObjectCompatibleMessage(ClientMessage message, - ClientSession session, - ConnectionFactoryOptions options) { - super(message, session, options); - } - - public ActiveMQObjectCompatibleMessage(ObjectMessage foreign, - ClientSession session, - ConnectionFactoryOptions options) throws JMSException { - super(foreign, session, options); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java deleted file mode 100644 index bb2fda6..0000000 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.activemq.artemis.jms.client.compatible1X; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.StreamMessage; - -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage; - -public class ActiveMQStreamCompatibleMessage extends ActiveMQStreamMessage { - - @Override - protected SimpleString checkPrefix(SimpleString address) { - return ActiveMQCompatibleMessage.checkPrefix1X(address); - } - - - @Override - public Destination getJMSReplyTo() throws JMSException { - if (replyTo == null) { - replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); - } - return replyTo; - } - - public ActiveMQStreamCompatibleMessage(ClientSession session) { - super(session); - } - - public ActiveMQStreamCompatibleMessage(ClientMessage message, ClientSession session) { - super(message, session); - } - - public ActiveMQStreamCompatibleMessage(StreamMessage foreign, ClientSession session) throws JMSException { - super(foreign, session); - } - - public ActiveMQStreamCompatibleMessage() { - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java deleted file mode 100644 index 451c582..0000000 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.activemq.artemis.jms.client.compatible1X; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.TextMessage; - -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; - -public class ActiveMQTextCompabileMessage extends ActiveMQTextMessage { - - - @Override - public Destination getJMSReplyTo() throws JMSException { - if (replyTo == null) { - replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); - } - return replyTo; - } - - public ActiveMQTextCompabileMessage(ClientSession session) { - super(session); - } - - public ActiveMQTextCompabileMessage(ClientMessage message, ClientSession session) { - super(message, session); - } - - public ActiveMQTextCompabileMessage(TextMessage foreign, ClientSession session) throws JMSException { - super(foreign, session); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/292566e3/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java ---------------------------------------------------------------------- diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java index ef23d50..33c6445 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java @@ -41,7 +41,6 @@ import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; import org.apache.activemq.artemis.ra.ActiveMQRALogger; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; import org.apache.activemq.artemis.service.extensions.ServiceUtils; @@ -87,8 +86,6 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList private volatile boolean connected; - private boolean enable1XPrefix; - public ActiveMQMessageHandler(final ConnectionFactoryOptions options, final ActiveMQActivation activation, final TransactionManager tm, @@ -108,8 +105,6 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList logger.trace("setup()"); } - this.enable1XPrefix = activation.getConnectionFactory().isEnable1xPrefixes(); - ActiveMQActivationSpec spec = activation.getActivationSpec(); String selector = spec.getMessageSelector(); @@ -286,12 +281,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList logger.trace("onMessage(" + message + ")"); } - ActiveMQMessage msg; - if (enable1XPrefix) { - msg = ActiveMQCompatibleMessage.createMessage(message, session, options); - } else { - msg = ActiveMQMessage.createMessage(message, session, options); - } + ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session, options); + msg.setEnable1xPrefixes(activation.getConnectionFactory().isEnable1xPrefixes()); boolean beforeDelivery = false;
