04-30-2015 08:34 AM
public class CustomFailedJobCommandFactory implements FailedJobCommandFactory{
public Command<Object> getCommand(String jobId, Throwable exception) {
return new NoJobRetriesCmd(jobId, exception);
}
}
public class NoJobRetriesCmd implements Command<Object> {
protected Throwable exception;
protected String jobId;
public NoJobRetriesCmd(String jobId, Throwable exception) {
this.jobId = jobId;
this.exception = exception;
}
public Object execute(CommandContext commandContext) {
JobEntity job = Context.getCommandContext().getJobEntityManager().findJobById(jobId);
job.setRetries(0);
job.setLockOwner(null);
job.setLockExpirationTime(null);
if(exception != null) {
job.setExceptionMessage(exception.getMessage());
job.setExceptionStacktrace(getExceptionStacktrace());
}
JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor);
TransactionContext transactionContext = commandContext.getTransactionContext();
transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification);
return null;
}
private String getExceptionStacktrace() {
StringWriter stringWriter = new StringWriter();
exception.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
}
}
05-05-2015 03:57 AM
05-07-2015 08:58 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.