{
for (Connector c : _driver.connectors())
{
Connection connection = c.getConnection();
_logger.log(Level.FINE, "Attempting to get message from " + connection);
Delivery delivery = connection.getWorkHead();
while (delivery != null)
{
if (delivery.isReadable() && !delivery.isPartial())
{
_logger.log(Level.FINE, "Readable delivery found: " + delivery);
int size = read((Receiver) delivery.getLink());
Message message = _messageFactory.createMessage();
message.decode(_buffer, 0, size);
_incoming.add(delivery);
_distributed--;
delivery.getLink().advance();
return message;
}
else
{
_logger.log(Level.FINE, "Delivery not readable: " + delivery);
delivery = delivery.getWorkNext();
}
}
}
return null;
}