use of com.amazonaws.services.dynamodbv2.model.ExpiredIteratorException in project camel by apache.
the class DdbStreamConsumer method poll.
@Override
protected int poll() throws Exception {
GetRecordsResult result;
try {
GetRecordsRequest req = new GetRecordsRequest().withShardIterator(shardIteratorHandler.getShardIterator(null)).withLimit(getEndpoint().getMaxResultsPerRequest());
result = getClient().getRecords(req);
} catch (ExpiredIteratorException e) {
LOG.warn("Expired Shard Iterator, attempting to resume from " + lastSeenSequenceNumber, e);
GetRecordsRequest req = new GetRecordsRequest().withShardIterator(shardIteratorHandler.getShardIterator(lastSeenSequenceNumber)).withLimit(getEndpoint().getMaxResultsPerRequest());
result = getClient().getRecords(req);
}
List<Record> records = result.getRecords();
Queue<Exchange> exchanges = createExchanges(records, lastSeenSequenceNumber);
int processedExchangeCount = processBatch(CastUtils.cast(exchanges));
shardIteratorHandler.updateShardIterator(result.getNextShardIterator());
if (!records.isEmpty()) {
lastSeenSequenceNumber = records.get(records.size() - 1).getDynamodb().getSequenceNumber();
}
return processedExchangeCount;
}
Aggregations