Changing control flow during execution

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

Changing control flow during execution

Jump to solution

I would like to know if it is possible to change the control flow of a process during execution.

For example in the following process:example

It is possible to jump form "Service Task 2" directly to "User Task 4" or maybe going back to "User Task 1"?

I read in documentation about ActivityBehavior class that can be invoked from a Java Service Task and there is stated that there is the possibility to change control flow of the process, but how can I do that?

I didn't find anything about how that can be done and I am also wondering if it is possible doing such a thing only from a Java Service Task or there is the possibility (always using the example) to go, for example, from "User Task 1" directly to "User Task 4" and then maybe going back to "Service Task 2" (?).

So my question is more in general: is there the possibility to change control flow in some way with Activiti?

I thank in advance everyone that will answer to my question.

1 Solution

Accepted Solutions
Highlighted
Active Member II

Re: Changing control flow during execution

Jump to solution

I solved as described here  

View solution in original post

4 Replies
Highlighted
Intermediate

Re: Changing control flow during execution

Jump to solution

It is possible but one needs to be very careful.
Every execution has an activityId associated with it, you can update the activity Id of an execution and the task will effectively move from one step to another.
Where this can become complex is the data dependencies associated with the process. If you skip a step, then perhaps the data enrichment associated with that step doesnt happen, then if a subsequent step relies on this data being populated you will get a failure.

Going backward in a process can cause the same sort of problem, as forms or services that are called assume a current state and jumping around breaks that paradigm.

The entire reason for having a defined process is to enforce specific paths of execution. If you need to move between different states, then model your process accordingly (i.e. not in a straight line),

Regards,

Greg

Highlighted
Active Member II

Re: Changing control flow during execution

Jump to solution

Thank you!

If I would like to modify anyways the activityId associated with the execution (even if it is a bad practice), how can I do that? I mean, it can only be done from an ActivityBehavior class or also from my main class?

Also, if it is possible to do it from the main class, how can I access the execution variable associated with the current process?

In both cases, which method I should call on the execution variable?

I apologize if I am asking too many questions, but I'm a novice with Activiti.

Highlighted
Intermediate

Re: Changing control flow during execution

Jump to solution

The following thread is a little old,  but should answer all of your questions.
I believe Martin also added a github project that demonstrates the mechanism.

https://community.alfresco.com/message/794649-re-whats-the-best-way-to-design-a-process-which-allows... 

Cheers,

Greg

bp3‌

Highlighted
Active Member II

Re: Changing control flow during execution

Jump to solution

I solved as described here  

View solution in original post