Search code examples
workflowaem

Terminate workflow with stacktrace and message


I have a workflow step and want to terminate the whole workflow with stacktrace if any error occurs.

@Component
@Properties({
        @Property(name = Constants.SERVICE_DESCRIPTION, value = "Workflow"),
        @Property(name = "process.label", value = "Workflow Step") })
public class WorkflowStep implements WorkflowProcess {

    @Override
    public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)throws WorkflowException {       
        try {
            ... doing some stuff ...
        } catch (Exception e) {
            workflowSession.terminateWorkflow(workItem.getWorkflow());          
        }
    }
}

How to put stacktrace/error message to terminated workflow?


Solution

  • Since there are maintenance jobs cleaning up workflows from time to time, I would suggest to not write staktraces to the workflow at all. There are options, for example you could add comments or just add properties to the nodes, ... but I would suggest to log things in the error logs and - if needed - generate a mail...

    BR, Oliver