activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [2/3] activemq-artemis git commit: ARTEMIS-944 - Broker can't convert AMQP python message to Openwire format
Date Tue, 07 Feb 2017 14:48:44 GMT
ARTEMIS-944 - Broker can't convert AMQP python message to Openwire format

https://issues.apache.org/jira/browse/ARTEMIS-944


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f268c101
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f268c101
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f268c101

Branch: refs/heads/master
Commit: f268c101afeb42a3bfb81f71c34c5615cb94b5cf
Parents: d937e8a
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Tue Feb 7 13:39:03 2017 +0000
Committer: Andy Taylor <andy.tayls67@gmail.com>
Committed: Tue Feb 7 14:02:20 2017 +0000

----------------------------------------------------------------------
 .../openwire/OpenWireMessageConverter.java      |  8 +++-
 .../crossprotocol/AMQPToOpenwireTest.java       | 41 ++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f268c101/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
index 950210b..076b01f 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
@@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerMessage;
 import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.artemis.reader.MessageUtil;
 import org.apache.activemq.artemis.spi.core.protocol.MessageConverter;
 import org.apache.activemq.artemis.utils.DataConstants;
 import org.apache.activemq.artemis.utils.TypedProperties;
@@ -772,7 +773,12 @@ public class OpenWireMessageConverter implements MessageConverter {
                if (prop instanceof SimpleString) {
                   amqMsg.setObjectProperty(s.toString(), prop.toString());
                } else {
-                  amqMsg.setObjectProperty(s.toString(), prop);
+                  if (keyStr.equals(MessageUtil.JMSXDELIVERYCOUNT) && prop instanceof
Long) {
+                     Long l = (Long) prop;
+                     amqMsg.setObjectProperty(s.toString(), l.intValue());
+                  } else {
+                     amqMsg.setObjectProperty(s.toString(), prop);
+                  }
                }
             } catch (JMSException e) {
                throw new IOException("exception setting property " + s + " : " + prop, e);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f268c101/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java
index dacd2cb..72a862e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/AMQPToOpenwireTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.tests.integration.crossprotocol;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
+import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.ObjectMessage;
@@ -25,6 +26,7 @@ import javax.jms.Queue;
 import javax.jms.Session;
 import java.io.ByteArrayInputStream;
 import java.io.ObjectInputStream;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.concurrent.TimeUnit;
 
@@ -37,7 +39,14 @@ import org.apache.activemq.artemis.core.server.RoutingType;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.jms.server.JMSServerManager;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.transport.amqp.client.AmqpClient;
+import org.apache.activemq.transport.amqp.client.AmqpConnection;
+import org.apache.activemq.transport.amqp.client.AmqpMessage;
+import org.apache.activemq.transport.amqp.client.AmqpSender;
+import org.apache.activemq.transport.amqp.client.AmqpSession;
 import org.apache.qpid.jms.JmsConnectionFactory;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.messaging.Header;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -113,4 +122,36 @@ public class AMQPToOpenwireTest extends ActiveMQTestBase {
          }
       }
    }
+
+   @Test
+   public void testDeliveryCountMessage() throws Exception {
+      AmqpClient client = new AmqpClient(new URI("tcp://127.0.0.1:61616"), null, null);
+      AmqpConnection amqpconnection = client.connect();
+      try {
+         AmqpSession session = amqpconnection.createSession();
+         AmqpSender sender = session.createSender(queueName);
+         AmqpMessage message = new AmqpMessage();
+         message.setMessageId("MessageID:" + 0);
+         message.getWrappedMessage().setHeader(new Header());
+         message.getWrappedMessage().getHeader().setDeliveryCount(new UnsignedInteger(2));
+         sender.send(message);
+      } finally {
+         amqpconnection.close();
+      }
+
+      Connection connection = null;
+      try {
+         connection = factory.createConnection();
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = session.createQueue(queueName);
+         MessageConsumer consumer = session.createConsumer(queue);
+         connection.start();
+         Message receive = consumer.receive(5000);
+         assertNotNull(receive);
+      } finally {
+         if (connection != null) {
+            connection.close();
+         }
+      }
+   }
 }


Mime
View raw message