use of com.amazonaws.services.sqs.model.QueueDoesNotExistException in project camel by apache.
the class SqsConsumer method poll.
@Override
protected int poll() throws Exception {
// must reset for each poll
shutdownRunningTask = null;
pendingExchanges = 0;
ReceiveMessageRequest request = new ReceiveMessageRequest(getQueueUrl());
request.setMaxNumberOfMessages(getMaxMessagesPerPoll() > 0 ? getMaxMessagesPerPoll() : null);
request.setVisibilityTimeout(getConfiguration().getVisibilityTimeout() != null ? getConfiguration().getVisibilityTimeout() : null);
request.setWaitTimeSeconds(getConfiguration().getWaitTimeSeconds() != null ? getConfiguration().getWaitTimeSeconds() : null);
if (attributeNames != null) {
request.setAttributeNames(attributeNames);
}
if (messageAttributeNames != null) {
request.setMessageAttributeNames(messageAttributeNames);
}
LOG.trace("Receiving messages with request [{}]...", request);
ReceiveMessageResult messageResult = null;
try {
messageResult = getClient().receiveMessage(request);
} catch (QueueDoesNotExistException e) {
LOG.info("Queue does not exist....recreating now...");
reConnectToQueue();
messageResult = getClient().receiveMessage(request);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Received {} messages", messageResult.getMessages().size());
}
Queue<Exchange> exchanges = createExchanges(messageResult.getMessages());
return processBatch(CastUtils.cast(exchanges));
}
Aggregations