_prefetchLowMark = defaultPrefetchLowMark;
if (_acknowledgeMode == NO_ACKNOWLEDGE)
{
_queue =
new FlowControllingBlockingQueue(_prefetchHighMark, _prefetchLowMark,
new FlowControllingBlockingQueue.ThresholdListener()
{
private final AtomicBoolean _suspendState = new AtomicBoolean();
public void aboveThreshold(int currentValue)
{
// If the session has been closed don't waste time creating a thread to do
// flow control
if (!(AMQSession.this.isClosed() || AMQSession.this.isClosing()))
{
// Only execute change if previous state
// was False
if (!_suspendState.getAndSet(true))
{
if (_logger.isDebugEnabled())
{
_logger.debug(
"Above threshold(" + _prefetchHighMark
+ ") so suspending channel. Current value is " + currentValue);
}
try
{
Threading.getThreadFactory().createThread(new SuspenderRunner(_suspendState)).start();
}
catch (Exception e)
{
throw new RuntimeException("Failed to create thread", e);
}
}
}
}
public void underThreshold(int currentValue)
{
// If the session has been closed don't waste time creating a thread to do
// flow control
if (!(AMQSession.this.isClosed() || AMQSession.this.isClosing()))
{
// Only execute change if previous state
// was true
if (_suspendState.getAndSet(false))
{
if (_logger.isDebugEnabled())
{
_logger.debug(
"Below threshold(" + _prefetchLowMark
+ ") so unsuspending channel. Current value is " + currentValue);
}
try
{
Threading.getThreadFactory().createThread(new SuspenderRunner(_suspendState)).start();
}
catch (Exception e)
{
throw new RuntimeException("Failed to create thread", e);
}
}
}
}
});
}
else
{
_queue = new FlowControllingBlockingQueue(_prefetchHighMark, null);
}
// Add creation logging to tie in with the existing close logging
if (_logger.isDebugEnabled())
{