activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: [AMQ-6702] add maxProducersToAudit and maxAuditDepth to dead letter strategy to cofigure the audit, fix and test
Date Tue, 13 Jun 2017 13:26:34 GMT
Repository: activemq
Updated Branches:
  refs/heads/master a1e595c18 -> b6cb0eace


[AMQ-6702] add maxProducersToAudit and maxAuditDepth to dead letter strategy to cofigure the
audit, fix and test


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

Branch: refs/heads/master
Commit: b6cb0eacea632239fa6bf3a6c66ba1570c3c9af7
Parents: a1e595c
Author: gtully <gary.tully@gmail.com>
Authored: Tue Jun 13 14:26:15 2017 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Tue Jun 13 14:26:15 2017 +0100

----------------------------------------------------------------------
 .../policy/AbstractDeadLetterStrategy.java      | 17 ++++++++
 .../broker/policy/DeadLetterExpiryTest.java     | 43 ++++++++++++++++++++
 2 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/b6cb0eac/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/AbstractDeadLetterStrategy.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/AbstractDeadLetterStrategy.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/AbstractDeadLetterStrategy.java
index ed376b7..fa6532b 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/AbstractDeadLetterStrategy.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/AbstractDeadLetterStrategy.java
@@ -107,4 +107,21 @@ public abstract class AbstractDeadLetterStrategy implements DeadLetterStrategy
{
     public void setExpiration(long expiration) {
         this.expiration = expiration;
     }
+
+    public int getMaxProducersToAudit() {
+        return messageAudit.getMaximumNumberOfProducersToTrack();
+    }
+
+    public void setMaxProducersToAudit(int maxProducersToAudit) {
+        messageAudit.setMaximumNumberOfProducersToTrack(maxProducersToAudit);
+    }
+
+    public void setMaxAuditDepth(int maxAuditDepth) {
+        messageAudit.setAuditDepth(maxAuditDepth);
+    }
+
+    public int getMaxAuditDepth() {
+        return messageAudit.getAuditDepth();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/b6cb0eac/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterExpiryTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterExpiryTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterExpiryTest.java
index 25a98b9..37a6039 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterExpiryTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/DeadLetterExpiryTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.broker.policy;
 
+import javax.jms.DeliveryMode;
 import javax.jms.Destination;
 import javax.jms.Message;
 import javax.jms.Queue;
@@ -63,6 +64,23 @@ public class DeadLetterExpiryTest extends DeadLetterTest {
         pMap.put(new ActiveMQQueue("loop"), buggyLoopingDLQPolicy);
         pMap.put(new ActiveMQQueue("DLQ.loop"), buggyLoopingDLQPolicy);
 
+        SharedDeadLetterStrategy auditConfigured = new SharedDeadLetterStrategy();
+        auditConfigured.setDeadLetterQueue(new ActiveMQQueue("DLQ.auditConfigured"));
+        auditConfigured.setProcessNonPersistent(true);
+        auditConfigured.setProcessExpired(true);
+        auditConfigured.setMaxProducersToAudit(1);
+        auditConfigured.setMaxAuditDepth(10);
+        PolicyEntry auditConfiguredDlqPolicy = new PolicyEntry();
+        auditConfiguredDlqPolicy.setDeadLetterStrategy(auditConfigured);
+        auditConfiguredDlqPolicy.setExpireMessagesPeriod(1000);
+
+        pMap.put(new ActiveMQQueue("Comp.One"), auditConfiguredDlqPolicy);
+        pMap.put(new ActiveMQQueue("Comp.Two"), auditConfiguredDlqPolicy);
+
+        PolicyEntry auditConfiguredPolicy = new PolicyEntry();
+        auditConfiguredPolicy.setEnableAudit(false); // allow duplicates through the cursor
+        pMap.put(new ActiveMQQueue("DLQ.auditConfigured"), auditConfiguredPolicy);
+
         PolicyEntry policyWithExpiryProcessing = pMap.getDefaultEntry();
         policyWithExpiryProcessing.setExpireMessagesPeriod(1000);
         pMap.setDefaultEntry(policyWithExpiryProcessing);
@@ -122,6 +140,29 @@ public class DeadLetterExpiryTest extends DeadLetterTest {
 
     }
 
+    public void testAuditConfigured() throws Exception {
+        destination = new ActiveMQQueue("Comp.One,Comp.Two");
+        connection.start();
+
+        messageCount = 1;
+        timeToLive = 2000;
+        deliveryMode = DeliveryMode.NON_PERSISTENT;
+        sendMessages();
+        sendMessages();
+
+        assertTrue("all messages expired even duplicates!", Wait.waitFor(new Wait.Condition()
{
+            @Override
+            public boolean isSatisified() throws Exception {
+                try {
+                    QueueViewMBean queueViewMBean = getProxyToQueue("DLQ.auditConfigured");
+                    LOG.info("Queue " + queueViewMBean.getName() + ", size:" + queueViewMBean.getQueueSize());
+                    return queueViewMBean.getQueueSize() == 4;
+                } catch (Exception expectedTillExpiry) {}
+                return false;
+            }
+        }));
+    }
+
     public void testNoDLQLoop() throws Exception {
         destination = new ActiveMQQueue("loop");
         messageCount = 2;
@@ -170,6 +211,8 @@ public class DeadLetterExpiryTest extends DeadLetterTest {
 
     protected void setUp() throws Exception {
         transactedMode = true;
+        deliveryMode = DeliveryMode.PERSISTENT;
+        timeToLive = 0;
         super.setUp();
     }
 


Mime
View raw message