protected int poll() throws Exception {
// must reset for each poll
shutdownRunningTask = null;
pendingExchanges = 0;
try {
Messages messages = null;
if (getEndpoint().getConfiguration().getTimeout() > 0) {
messages = getEndpoint().getQueue().get(getMaxMessagesPerPoll(), getEndpoint().getConfiguration().getTimeout());
LOG.trace("Receiving messages with request [messagePerPoll{}, timeout {}]...", getMaxMessagesPerPoll(), getEndpoint().getConfiguration().getTimeout());
} else {
messages = getEndpoint().getQueue().get(getMaxMessagesPerPoll());
LOG.trace("Receiving messages with request [messagePerPoll {}]...", getMaxMessagesPerPoll());
}
LOG.trace("Received {} messages", messages.getMessages().length);
Queue<Exchange> exchanges = createExchanges(messages.getMessages());
return processBatch(CastUtils.cast(exchanges));
} catch (EmptyQueueException e) {
return 0;
}
}