if (packet instanceof PingResponse)
return true;
if (packet instanceof NotificationPacket)
{
final NotificationPacket notifPacket = (NotificationPacket)packet;
final AbstractMessage prefetchedMessage = notifPacket.getMessage();
boolean acceptedByConsumer = false;
AbstractSession session = lookupRegisteredSession(notifPacket.getSessionId());
if (session != null)
{
RemoteMessageConsumer consumer = (RemoteMessageConsumer)session.lookupRegisteredConsumer(notifPacket.getConsumerId());
if (consumer != null)
acceptedByConsumer = consumer.addToPrefetchQueue(prefetchedMessage,notifPacket.getPrefetchCapacity());
else
log.debug("#"+id+" No such consumer : #"+notifPacket.getSessionId()+":"+notifPacket.getConsumerId()); // Consumer was concurrently closed or not yet registered
}
else
log.debug("#"+id+" No such session : #"+notifPacket.getSessionId()); // Session was concurrently closed
// If the consumer was already gone, we need to rollback the prefetched message on the server side
if (!acceptedByConsumer)
scheduleRollback(notifPacket.getSessionId(),
notifPacket.getConsumerId(),
prefetchedMessage);
return true;
}