if (timeout == 0)
{
if (!connection.isStarted())
return null;
AbstractMessage message = localQueue.get((LocalSession)session,
transactionSet,
selector);
if (message == null)
return null;
if (traceEnabled)
log.trace(session+" [GET] in "+localQueue+" - "+message);
if (duplicateRequired)
message = MessageTools.duplicate(message);
message.markAsReadOnly();
return message;
}
// Wait loop
long now = System.currentTimeMillis();
long startTime = now;
// Passive wait
while (!closed && (timeout < 0 || (now - startTime < timeout)))
{
// Don't do anything if connection is not started
if (connection.isStarted())
{
// Try obtaining something from target queue
AbstractMessage message = localQueue.get((LocalSession)session,
transactionSet,
selector);
if (message != null)
{
if (traceEnabled)
log.trace(session+" [GET] in "+localQueue+" - "+message);
if (duplicateRequired)
message = MessageTools.duplicate(message);
message.markAsReadOnly();
return message;
}
}