int repeatSeconds = new Double(visibilityTimeout.doubleValue() * 1.5).intValue(); //
LOG.debug("period :" + period);
LOG.debug("repeatSeconds :" + repeatSeconds);
final ScheduledFuture<?> scheduledFuture = this.scheduledExecutor.scheduleAtFixedRate(
new TimeoutExtender(exchange, repeatSeconds), delay, period, TimeUnit.SECONDS);
exchange.addOnCompletion(new Synchronization() {
@Override
public void onComplete(Exchange exchange) {
cancelExtender(exchange);
}
@Override
public void onFailure(Exchange exchange) {
cancelExtender(exchange);
}
private void cancelExtender(Exchange exchange) {
// cancel task as we are done
LOG.trace("Processing done so cancelling TimeoutExtender task for exchangeId: {}", exchange.getExchangeId());
scheduledFuture.cancel(true);
}
});
}
// add on completion to handle after work when the exchange is done
exchange.addOnCompletion(new Synchronization() {
public void onComplete(Exchange exchange) {
processCommit(exchange);
}
public void onFailure(Exchange exchange) {