Only start Producer Flow Control thread when needed

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@961500 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2010-07-07 20:31:40 +00:00
parent b47da808d7
commit 89e538db7c
1 changed files with 7 additions and 10 deletions

View File

@ -198,7 +198,7 @@ public class Queue extends BaseDestination implements Task, UsageListener {
}
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Producer Flow Control Timeout Task is stopping");
LOG.debug(getName() + "P roducer Flow Control Timeout Task is stopping");
}
}
}
@ -548,6 +548,12 @@ public class Queue extends BaseDestination implements Task, UsageListener {
// for space.
final ProducerBrokerExchange producerExchangeCopy = producerExchange.copy();
synchronized (messagesWaitingForSpace) {
// Start flow control timeout task
// Prevent trying to start it multiple times
if (!flowControlTimeoutTask.isAlive()) {
flowControlTimeoutTask.setName(getName()+" Producer Flow Control Timeout Task");
flowControlTimeoutTask.start();
}
messagesWaitingForSpace.put(message.getMessageId(), new Runnable() {
public void run() {
@ -804,15 +810,6 @@ public class Queue extends BaseDestination implements Task, UsageListener {
if (getExpireMessagesPeriod() > 0) {
scheduler.schedualPeriodically(expireMessagesTask, getExpireMessagesPeriod());
}
flowControlTimeoutTask.setName("Producer Flow Control Timeout Task");
// Start flow control timeout task
// Prevent trying to start it multiple times
if (!flowControlTimeoutTask.isAlive()) {
flowControlTimeoutTask.start();
}
doPageIn(false);
}