From 4742c7d86f7312d2b023b8120064341051ab348d Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Wed, 1 May 2013 20:49:08 +0000 Subject: [PATCH] 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 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1478183 13f79535-47bb-0310-9956-ffa450edef68 --- .../broker/region/PrefetchSubscription.java | 6 ++ .../org/apache/activemq/bugs/AMQ4504Test.java | 82 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java index e46d80c9d3..db3c6089a9 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/PrefetchSubscription.java @@ -415,6 +415,12 @@ public abstract class PrefetchSubscription extends AbstractSubscription { 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); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java new file mode 100644 index 0000000000..64204bd758 --- /dev/null +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4504Test.java @@ -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