@Override protected void loop() { if (!this.isCancelled()) { Duration renewInterval = this.getNextRenewInterval(); if (renewInterval != null && !renewInterval.isNegative()) { this.timerFuture = Timer.schedule(() -> { TRACE_LOGGER.debug("Renewing lock on '{}'", this.messageIdentifier); this.innerReceiver.renewMessageLockAsync(message).handleAsync((v, renewLockEx) -> { if (renewLockEx != null) { renewLockEx = ExceptionUtil.extractAsyncCompletionCause(renewLockEx); TRACE_LOGGER.error("Renewing lock on '{}' failed", this.messageIdentifier, renewLockEx); this.messageAndSessionPump.notifyExceptionToMessageHandler(renewLockEx, ExceptionPhase.RENEWMESSAGELOCK); if (!(renewLockEx instanceof MessageLockLostException || renewLockEx instanceof OperationCancelledException)) { this.loop(); } } else { TRACE_LOGGER.debug("Renewed lock on '{}'", this.messageIdentifier); this.loop(); } return null; }, MessagingFactory.INTERNAL_THREAD_POOL); }, renewInterval, TimerType.OneTimeRun); } } }