From 1ba35323650b403d403523927ef628d83f0fcf23 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Fri, 30 Nov 2007 22:39:26 +0000 Subject: [PATCH] handle the inactivity actions in an async thread so that the schedular thread does not get blocked. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@599993 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/InactivityMonitor.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java b/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java index dfb2f55b9b..dfe6c03e50 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java @@ -74,13 +74,18 @@ public class InactivityMonitor extends TransportFilter { if (!commandSent.get()) { LOG.trace("No message sent since last write check, sending a KeepAliveInfo"); - try { - synchronized (writeChecker) { - next.oneway(new KeepAliveInfo()); - } - } catch (IOException e) { - onException(e); - } + // TODO: use a thread pool for this.. + Thread thread = new Thread("ActiveMQ: Activity Generator: "+next.getRemoteAddress()) { + public void run() { + try { + oneway(new KeepAliveInfo()); + } catch (IOException e) { + onException(e); + } + }; + }; + thread.setDaemon(true); + thread.start(); } else { LOG.trace("Message sent since last write check, resetting flag"); } @@ -96,9 +101,18 @@ public class InactivityMonitor extends TransportFilter { if (!commandReceived.get()) { LOG.debug("No message received since last read check for " + toString() + "! Throwing InactivityIOException."); - synchronized (readChecker) { - onException(new InactivityIOException("Channel was inactive for too long.")); - } + + // TODO: use a thread pool for this.. + Thread thread = new Thread("ActiveMQ: Inactivity Handler: "+next.getRemoteAddress()) { + public void run() { + synchronized (readChecker) { + onException(new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress())); + } + }; + }; + thread.setDaemon(true); + thread.start(); + } else { LOG.trace("Message received since last read check, resetting flag: "); }