Source:
public void run() { long backoffDelay = 10000; int backoffAttempts = 1; int maxBackoffAttempts = 5; for (ObjectEnhancementService service : services) { if (message.getFilteredServices() != null && !message.getFilteredServices().contains(service.getClass().getName())) { continue; } try { if (!service.isApplicable(message)) { continue; } } catch (EnhancementException e) { LOG.error("Error determining applicability for service " + service.getClass().getName() + " and object " + message.getTargetID(), e); } while (backoffAttempts <= maxBackoffAttempts) { try { if (fedoraManagementClient.isRepositoryAvailable()) { applyService(service); metricsClient.incrFinishedEnhancement(service.getClass().getName()); break; } else { throw new WebServiceIOException("Unable to connect to Fedora"); } } catch (ServiceException | WebServiceIOException e) { LOG.warn("Unable to connect to fedora. Unable to run job for " + service.getClass().getName() + ". Retry attempt " + backoffAttempts); try { Thread.sleep(backoffDelay * backoffAttempts); } catch (InterruptedException e1) { LOG.warn("Back off time was interrupted for job " + service.getClass().getName()); } if (backoffAttempts == maxBackoffAttempts) { LOG.warn("Unable to connect to fedora. Unable to run job for " + service.getClass().getName()); metricsClient.incrFailedEnhancement(service.getClass().getName()); } backoffAttempts++; } catch (EnhancementException e) { LOG.error("Error applying service " + service.getClass().getName() + " to object " + message.getTargetID(), e); metricsClient.incrFailedEnhancement(service.getClass().getName()); } catch (Throwable t) { metricsClient.incrFailedEnhancement(service.getClass().getName()); throw t; } } } }

Target:
public void run() { int backoffAttempts = 1; for (ObjectEnhancementService service : services) { if (message.getFilteredServices() != null && !message.getFilteredServices().contains(service.getClass().getName())) { continue; } try { if (!service.isApplicable(message)) { continue; } } catch (EnhancementException e) { LOG.error("Error determining applicability for service " + service.getClass().getName() + " and object " + message.getTargetID(), e); } while (true) { try { if (fedoraManagementClient.isRepositoryAvailable()) { applyService(service); metricsClient.incrFinishedEnhancement(service.getClass().getName()); return; } else { throw new ServiceException(new WebServiceIOException("Unable to connect to Fedora")); } } catch (ServiceException e) { if (e.getCause() instanceof WebServiceIOException) { LOG.warn("Unable to connect to fedora. Unable to run job for " + service.getClass().getName() + ". Retry attempt " + backoffAttempts); try { Thread.sleep(BACKOFF_DELAY * backoffAttempts); } catch (InterruptedException e1) { LOG.warn("Back off time was interrupted for job " + service.getClass().getName()); return; } backoffAttempts++; } else { return; } } catch (EnhancementException e) { LOG.error("Error applying service " + service.getClass().getName() + " to object " + message.getTargetID(), e); metricsClient.incrFailedEnhancement(service.getClass().getName()); } catch (Throwable t) { metricsClient.incrFailedEnhancement(service.getClass().getName()); throw t; } } } }