From 91720daee7c3a1f2be5b38d922639750632b6a39 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Mon, 17 Apr 2006 15:29:43 +0000 Subject: [PATCH] On consumer close, wait for it's async threads to finish before returning. Was getting errors when async acks were sent and the subscription was allready closed. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@394705 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/ActiveMQMessageConsumer.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index 3a2d634cfa..826f623b67 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -45,8 +45,10 @@ import org.apache.activemq.util.JMSExceptionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService; +import edu.emory.mathcs.backport.java.util.concurrent.Executors; +import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean; -import edu.emory.mathcs.backport.java.util.concurrent.*; /** * A client uses a MessageConsumer object to receive messages @@ -560,6 +562,11 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC deliverAcks();//only processes optimized acknowledgements if (executorService!=null){ executorService.shutdown(); + try { + executorService.awaitTermination(60, TimeUnit.SECONDS); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } if ((session.isTransacted() || session.isDupsOkAcknowledge())) { acknowledge();