Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Terminating (forceful) a running workflow instance

dibyajyotis2501
Level 2
Level 2

I'm trying to terminate certain workflows based upon threshold value of custom batch processing limit. But when I'm trying to terminate by using WF api, I could notice a strange behavior in the below snippet.

1:   WorkflowSession wfs = workflowService.getWorkflowSession(rr.adaptTo(Session.class));

2:   try {

3:      log.debug(" Is Workflow active?? "+wf.isActive());

4:      wfs.terminateWorkflow(wf);

5:   } catch (Exception e) {

6:   e.printStackTrace();

     }

Just before calling the terminateWorkflow method, if I check the wf state by various ways e.g.

i)   By using isActive() method

ii)  By retrieving the valuemap of the particular workflow id from the var/workflow/instances/server0..... path and checking the jcr property 'state'.

iii) By using WorkflowStatus interface

But even if all above steps show a workflow is RUNNING or active, yet when flow reaches line 4 immediately, exception is throws as:

java.lang.IllegalStateException: Workflow is already finished.

Has anyone faced any similar kind of scenario?

N.B.  - The execution is carried on single thread operation(of ActionManager) unlike multi-threaded execution.

0 Replies