Source:
<code>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); } <START> while (backoffAttempts <= maxBackoffAttempts) { <END> 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; } } } }</code><technical_language>While this, I started wondering if sense this retry Fedora is throws authentication/WebServiceIOException exception. reason failure issue job, environment, skipping job help. do think? sense increase delay retry in cases I mentioned? For startup of work daemon i fine for max retries giving queue lost. kind of nice get notifications of some sort failing, I want engineer this for long. lets hold need up</technical_language>

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; } } } }