From 0cf2cdc719de9031fca1bd161bed9cc921ea4d39 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Fri, 5 Dec 2008 06:44:41 +0000 Subject: [PATCH] Fix for https://issues.apache.org/activemq/browse/AMQ-2025 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@723614 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/activemq/ActiveMQSessionExecutor.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java index 4ad5ddb898..ba4d667d75 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQSessionExecutor.java @@ -19,6 +19,7 @@ package org.apache.activemq; import java.util.Iterator; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.JMSException; @@ -45,6 +46,7 @@ public class ActiveMQSessionExecutor implements Task { private boolean dispatchedBySessionPool; private TaskRunner taskRunner; private boolean startedOrWarnedThatNotStarted; + private AtomicBoolean taskRunnerCreated = new AtomicBoolean(); ActiveMQSessionExecutor(ActiveMQSession session) { this.session = session; @@ -88,15 +90,18 @@ public class ActiveMQSessionExecutor implements Task { if (!dispatchedBySessionPool) { if (session.isSessionAsyncDispatch()) { try { - if (taskRunner == null) { - taskRunner = session.connection.getSessionTaskRunner().createTaskRunner(this, "ActiveMQ Session: " + session.getSessionId()); + if (taskRunnerCreated.compareAndSet(false, true)) { + if (taskRunner == null) { + taskRunner = session.connection.getSessionTaskRunner().createTaskRunner(this, + "ActiveMQ Session: " + session.getSessionId()); + } } taskRunner.wakeup(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } else { - while (iterate()) { + while (iterate()) { } } } @@ -141,6 +146,7 @@ public class ActiveMQSessionExecutor implements Task { if (taskRunner != null) { taskRunner.shutdown(); taskRunner = null; + taskRunnerCreated.set(false); } } } catch (InterruptedException e) {