Author: gtully
Date: Wed May 1 20:49:08 2013
New Revision: 1478183
URL: http://svn.apache.org/r1478183
Log:
https://issues.apache.org/jira/browse/AMQ-4504 - ensure all dests in a
composite get a chance to dispatch to a consumer after an ack
Added:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
(with props)
Modified:
activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java
Modified:
activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java?rev=1478183&r1=1478182&r2=1478183&view=diff
==============================================================================
---
activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java
(original)
+++
activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java
Wed May 1 20:49:08 2013
@@ -415,6 +415,12 @@ public abstract class PrefetchSubscripti
if (callDispatchMatched && destination != null) {
destination.wakeup();
dispatchPending();
+
+ if (pending.isEmpty()) {
+ for (Destination dest : destinations) {
+ dest.wakeup();
+ }
+ }
} else {
LOG.debug("Acknowledgment out of sync (Normally occurs when
failover connection reconnects): "
+ ack);
Added:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java?rev=1478183&view=auto
==============================================================================
---
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
(added)
+++
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
Wed May 1 20:49:08 2013
@@ -0,0 +1,82 @@
+/**
+ * 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 javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+import static org.junit.Assert.assertNotNull;
+
+public class AMQ4504Test {
+
+ BrokerService brokerService;
+
+ @Before
+ public void setup() throws Exception {
+ brokerService = new BrokerService();
+ brokerService.setPersistent(false);
+ brokerService.start();
+ }
+
+ @After
+ public void stop() throws Exception {
+ brokerService.stop();
+ }
+
+ @Test
+ public void testCompositeDestConsumer() throws Exception {
+
+ final int numDests = 20;
+ final int numMessages = 200;
+ StringBuffer stringBuffer = new StringBuffer();
+ for (int i=0; i<numDests; i++) {
+ if (stringBuffer.length() != 0) {
+ stringBuffer.append(',');
+ }
+ stringBuffer.append("ST." + i);
+ }
+ stringBuffer.append("?consumer.prefetchSize=100");
+ ActiveMQQueue activeMQQueue = new
ActiveMQQueue(stringBuffer.toString());
+ ConnectionFactory factory = new
ActiveMQConnectionFactory(brokerService.getVmConnectorURI());
+ Connection connection = factory.createConnection();
+ connection.start();
+ MessageProducer producer = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE).createProducer(activeMQQueue);
+ for (int i=0; i<numMessages; i++) {
+ producer.send(new ActiveMQTextMessage());
+ }
+
+ MessageConsumer consumer = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE).createConsumer(activeMQQueue);
+ try {
+ for (int i=0; i< numMessages * numDests; i++) {
+ assertNotNull("recieved:" + i, consumer.receive(4000));
+ }
+ } finally {
+ connection.close();
+ }
+ }
+}
Propchange:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java
------------------------------------------------------------------------------
svn:keywords = Rev Date