activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5863 - fix and test - sequenceId state in messageid needs to be cleared before doing a store
Date Thu, 25 Jun 2015 11:51:49 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 97cd60fb7 -> b6fea8312


https://issues.apache.org/jira/browse/AMQ-5863 - fix and test - sequenceId state in messageid
needs to be cleared before doing a store


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

Branch: refs/heads/master
Commit: b6fea83126a5d0a7a99f9a6054e3eff17b40ff80
Parents: 97cd60f
Author: gtully <gary.tully@gmail.com>
Authored: Thu Jun 25 12:49:22 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Thu Jun 25 12:49:52 2015 +0100

----------------------------------------------------------------------
 .../apache/activemq/broker/region/Queue.java    |   1 +
 .../org/apache/activemq/util/BrokerSupport.java |   1 -
 .../activemq/store/kahadb/KahaDBStore.java      |   1 -
 .../bugs/AMQ5863CompositePublishTest.java       | 113 +++++++++++++++++++
 4 files changed, 114 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/b6fea831/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
index 232a7ba..af61e19 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
@@ -824,6 +824,7 @@ public class Queue extends BaseDestination implements Task, UsageListener,
Index
         try {
             message.getMessageId().setBrokerSequenceId(getDestinationSequenceId());
             if (store != null && message.isPersistent()) {
+                message.getMessageId().setFutureOrSequenceLong(null);
                 try {
                     if (messages.isCacheEnabled()) {
                         result = store.asyncAddQueueMessage(context, message, isOptimizeStorage());

http://git-wip-us.apache.org/repos/asf/activemq/blob/b6fea831/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java b/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java
index ca19b8b..f3f3b78 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/util/BrokerSupport.java
@@ -55,7 +55,6 @@ public final class BrokerSupport {
         message.setDestination(deadLetterDestination);
         message.setTransactionId(null);
         message.setMemoryUsage(null);
-        message.getMessageId().setFutureOrSequenceLong(null);
         message.setRedeliveryCounter(0);
         boolean originalFlowControl = context.isProducerFlowControl();
         try {

http://git-wip-us.apache.org/repos/asf/activemq/blob/b6fea831/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
index 7e06a57..8ceef36 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
@@ -375,7 +375,6 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter
{
                 result.aquireLocks();
                 addQueueTask(this, result);
                 if (indexListener != null) {
-                    // allow concurrent dispatch by setting entry locator,
                     indexListener.onAdd(new IndexListener.MessageContext(context, message,
null));
                 }
                 return future;

http://git-wip-us.apache.org/repos/asf/activemq/blob/b6fea831/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java
new file mode 100644
index 0000000..615f3e5
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5863CompositePublishTest.java
@@ -0,0 +1,113 @@
+/**
+ * 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.bugs;
+
+import java.util.Arrays;
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.Session;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.TestSupport;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.broker.region.policy.PolicyEntry;
+import org.apache.activemq.broker.region.policy.PolicyMap;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(Parameterized.class)
+public class AMQ5863CompositePublishTest {
+    static Logger LOG = LoggerFactory.getLogger(AMQ5863CompositePublishTest.class);
+    String brokerUrl;
+    BrokerService brokerService;
+
+    @Parameterized.Parameter(0)
+    public TestSupport.PersistenceAdapterChoice persistenceAdapterChoice = TestSupport.PersistenceAdapterChoice.KahaDB;
+
+    @Parameterized.Parameters(name = "#store:{0}")
+    public static Iterable<Object[]> parameters() {
+        return Arrays.asList(new Object[][]{
+                {TestSupport.PersistenceAdapterChoice.KahaDB},
+                {TestSupport.PersistenceAdapterChoice.LevelDB},
+                {TestSupport.PersistenceAdapterChoice.JDBC}
+        });
+    }
+
+    @Before
+    public void startBroker() throws Exception {
+        brokerService = new BrokerService();
+        TestSupport.setPersistenceAdapter(brokerService, persistenceAdapterChoice);
+        brokerService.setDeleteAllMessagesOnStartup(true);
+        brokerService.setUseJmx(false);
+        brokerService.setAdvisorySupport(false);
+
+        PolicyMap policyMap = new PolicyMap();
+        PolicyEntry defaultEntry = new PolicyEntry();
+        defaultEntry.setUseCache(false);
+        defaultEntry.setExpireMessagesPeriod(0);
+        policyMap.setDefaultEntry(defaultEntry);
+        brokerService.setDestinationPolicy(policyMap);
+
+        TransportConnector transportConnector = brokerService.addConnector("tcp://0.0.0.0:0");
+        brokerService.start();
+        brokerUrl = transportConnector.getPublishableConnectString();
+    }
+
+    @After
+    public void stopBroker() throws Exception {
+        if (brokerService != null) {
+            brokerService.stop();
+        }
+    }
+
+    @Test
+    public void test() throws Exception {
+
+        ActiveMQQueue compositeSendTo = new ActiveMQQueue("one,two,three");
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrl);
+        connectionFactory.setWatchTopicAdvisories(false);
+
+        Connection connection = connectionFactory.createConnection();
+        connection.start();
+
+        try {
+
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            session.createProducer(compositeSendTo).send(session.createTextMessage("Bing"));
+
+            for (ActiveMQDestination dest : compositeSendTo.getCompositeDestinations()) {
+                Message message = session.createConsumer(dest).receive(5000);
+                LOG.info("From: " + dest + ", " + message.getJMSDestination());
+                assertNotNull("got message from: " + dest, message);
+            }
+
+        } finally {
+            connection.close();
+        }
+    }
+
+}


Mime
View raw message