ClientMessageInternal message;
// Must store handler in local variable since might get set to null
// otherwise while this is executing and give NPE when calling onMessage
MessageHandler theHandler = handler;
if (theHandler != null)
{
if (rateLimiter != null)
{
rateLimiter.limit();
}
failedOver = false;
synchronized (this)
{
message = buffer.poll();
}
if (message != null)
{
if (message.containsProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE))
{
//Ignore, this could be a relic from a previous receiveImmediate();
return;
}
boolean expired = message.isExpired();
flowControlBeforeConsumption(message);
if (!expired)
{
if (isTrace)
{
HornetQClientLogger.LOGGER.trace("Calling handler.onMessage");
}
final ClassLoader originalLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
public ClassLoader run()
{
ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(contextClassLoader);
return originalLoader;
}
});
onMessageThread = Thread.currentThread();
try
{
theHandler.onMessage(message);
}
finally
{
try
{