activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [activemq-artemis] branch master updated: ARTEMIS-2294 dupe detection for AMQP same as core
Date Fri, 12 Apr 2019 13:39:59 GMT
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 2dd0671  ARTEMIS-2294 dupe detection for AMQP same as core
     new eab3f22  This closes #2609
2dd0671 is described below

commit 2dd06716989820eeecad7f39faabfbb8f025f7f1
Author: Justin Bertram <jbertram@apache.org>
AuthorDate: Thu Apr 4 11:21:08 2019 -0500

    ARTEMIS-2294 dupe detection for AMQP same as core
---
 .../artemis/protocol/amqp/broker/AMQPMessage.java  |  2 +-
 .../tests/integration/amqp/AmqpSenderTest.java     | 23 +++++++++++++++++++++
 .../integration/amqp/JMSMessageProducerTest.java   | 24 ++++++++++++++++++++++
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index a122d7b..df35115 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -971,7 +971,7 @@ public class AMQPMessage extends RefCountMessage {
 
    @Override
    public Object getDuplicateProperty() {
-      return null;
+      return getObjectProperty(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID);
    }
 
    @Override
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSenderTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSenderTest.java
index 50d8828..dc1b6e4 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSenderTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSenderTest.java
@@ -20,6 +20,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.core.server.Queue;
 import org.apache.activemq.artemis.protocol.amqp.proton.AmqpSupport;
 import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
@@ -183,6 +184,28 @@ public class AmqpSenderTest extends AmqpClientTestSupport {
    }
 
    @Test(timeout = 60000)
+   public void testDuplicateDetection() throws Exception {
+      final int MSG_COUNT = 10;
+
+      AmqpClient client = createAmqpClient();
+      AmqpConnection connection = addConnection(client.connect());
+      AmqpSession session = connection.createSession();
+
+      AmqpSender sender = session.createSender(getQueueName(), true);
+
+      for (int i = 1; i <= MSG_COUNT; ++i) {
+         AmqpMessage message = new AmqpMessage();
+         message.setApplicationProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "123");
+         sender.send(message);
+      }
+
+      Wait.assertTrue("Only 1 message should arrive", () -> getProxyToQueue(getQueueName()).getMessageCount()
== 1);
+
+      sender.close();
+      connection.close();
+   }
+
+   @Test(timeout = 60000)
    public void testSenderCreditReplenishment() throws Exception {
       AtomicInteger counter = new AtomicInteger();
       CountDownLatch initialCredit = new CountDownLatch(1);
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageProducerTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageProducerTest.java
index 95f5a4b..2125ed8 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageProducerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageProducerTest.java
@@ -30,6 +30,7 @@ import javax.jms.TemporaryQueue;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 
+import org.apache.activemq.artemis.tests.util.Wait;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -96,6 +97,29 @@ public class JMSMessageProducerTest extends JMSClientTestSupport {
       }
    }
 
+   @Test(timeout = 30000)
+   public void testDuplicateDetection() throws Exception {
+      final int MSG_COUNT = 10;
+      Connection connection = createConnection();
+
+      try {
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = session.createQueue(getQueueName());
+         MessageProducer p = session.createProducer(null);
+
+         for (int i = 1; i <= MSG_COUNT; ++i) {
+            TextMessage message = session.createTextMessage();
+            message.setStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID.toString(),
"123");
+            // this will auto-create the address
+            p.send(queue, message);
+         }
+
+         Wait.assertTrue("Only 1 message should arrive", () -> getProxyToQueue(getQueueName()).getMessageCount()
== 1);
+      } finally {
+         connection.close();
+      }
+   }
+
    @Test(timeout = 60000)
    public void testAnonymousProducerAcrossManyDestinations() throws Exception {
       Connection connection = createConnection();


Mime
View raw message