O object,
MessageProcessor messageProcessor,
MuleEvent event) throws Exception
{
RetryPolicy retryPolicy = retryPolicyTemplate.createRetryInstance();
DefaultRetryContext retryContext = new DefaultRetryContext("Work Descriptor", metaInfo);
retryContext.setMuleContext(muleContext);
PolicyStatus status = null;
T result = null;
try
{
Exception cause = null;
do
{
try
{
result = this.next.execute(processCallback, object, messageProcessor, event);
if (retryPolicyTemplate.getNotifier() != null)
{
retryPolicyTemplate.getNotifier().onSuccess(retryContext);
}
return result;
}
catch (Exception e)
{
cause = e;
if (logger.isDebugEnabled())
{
logger.debug(cause.getMessage(), cause);
}
if (retryPolicyTemplate.getNotifier() != null)
{
retryPolicyTemplate.getNotifier().onFailure(retryContext, cause);
}
boolean isManagedException = false;
if (processCallback.getManagedExceptions() != null)
{
for (Class<? extends Exception> exceptionClass : processCallback.getManagedExceptions())
{
if (exceptionClass.isInstance(e))
{
isManagedException = true;
break;
}
}
}
if ((cause instanceof InterruptedException) || (cause instanceof InterruptedIOException))
{
logger.error("Process was interrupted (InterruptedException), ceasing process");
break;
}
else
{
if (isManagedException)
{
status = retryPolicy.applyPolicy(cause);
}
else
{
status = PolicyStatus.policyExhausted(cause);
}
}
}
}
while (status.isOk());
if ((status != null) && (!status.isOk()))
{
retryContext.setFailed(cause);
throw cause;
}
}
finally
{