cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to fail execution manually

jogin
Champ in-the-making
Champ in-the-making

Hi,

I would like to create one rest endpoint, in which I wanted to pass execution id and based on execution id, I would like fail the execution manually.

Is this possible, to fail execution manually? If yes, the how to do it ?

Thanks,

3 REPLIES 3

gdharley
Elite Collaborator
Elite Collaborator

When you say fail manually, what do you really mean?

Any exception will fail the process, but have an idea that this isnt what you really mean.

Please provide a scenario with more details.

Thanks,

Greg

jogin
Champ in-the-making
Champ in-the-making

Hi Greg,

Thanks for your reply.

My scenario is as below:

I have one workflow which has async job. This async job, actually triggers some another job that is not part of Activiti. Now, when this job gets failed, I would like to notify Activiti that this job gets failed and eventually, I would like to fail the process.

Now, my question is when job (that is not part of Activiti) fails, how could I fail the Activiti process ?

Thanks,

gdharley
Elite Collaborator
Elite Collaborator

Hi Jogin,

I am assuming you are creating a Java Delegate (Service Task) to call outside the workflow engine.
If the external call fails, have your service throw a BpmnError as shown in the following code snippet:

public class Example implements JavaDelegate {

    public void execute(DelegateExecution delegateExecution) throws Exception {
        try {
            /**
             *
             * My logic
             *
             */
        } catch(Exception e) {
            throw new BpmnError("Error code", e.getMessage());
        }

    }
}

This way, you can catch the error in your process using an Error Boundary event (make sure the error code you throw matches the boundary error code you are watching for.

Hope this helps,

Greg