public bool Iterate()
{
try
{
lock(this.consumers.SyncRoot)
{
// Deliver any messages queued on the consumer to their listeners.
foreach( MessageConsumer consumer in this.consumers.Values )
{
if(consumer.Iterate())
{
return true;
}
}
}
// No messages left queued on the listeners.. so now dispatch messages
// queued on the session
MessageDispatch message = messageQueue.DequeueNoWait();
if(message != null)
{
this.Dispatch(message);
return !messageQueue.Empty;
}
return false;
}
catch(Exception ex)
{
Tracer.DebugFormat("Caught Exception While Dispatching: {0}", ex.Message );
this.session.Connection.OnSessionException(this.session, ex);
}
return true;
}