cancel
Showing results for 
Search instead for 
Did you mean: 

Lock/Unlock objects due process workflow

edsonrichter
Confirmed Champ
Confirmed Champ
Hi!

I would like to know if there is any best practice reccomendation to lock/unlock objects involved in an workflow.
Let's say, I choose several orders that need to be cancelled.
The cancel process involves review the chosen orders, and then a sales manager to confirm cancellation.
Meanwhile, I would like to avoid anyone else to change the orders until the process is finished, manually cancelled or timed out.

Some ideas come to my mind:
1) I need to have a "lock table" since workflows must survive restarts of the app server. I suppose I need to record the process instance ID into this table, so I can track objects x processes and destroy process in case of forced unlock (item 2 ahead).
2) I need some way to unlock objects for a long while - and forcing the unlock must manually cancel the process itself.
3) Is better to lock objects from inside the process itself (for instance, after the objects review task), or is better to lock them before starting the process instance?
4) The event of error must call a task to unlock all objects?
5) Is there any generic "process listener" or "process instance listener" which I can use to lock and unlock objects (even in case of catastrofic failure)?

There are best practices which I can learn from about this topic?

Thanks,

Edson Richter
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
1) That would work. You would indeed link it to the process instance id
3) That's up to you. You can model it both ways.
4) That can also be modeled in the process, by adding everything in an embedded subprocess with a boundary event
5) There are geeneric listeners in Activiti, yes. But I don't think they'll be useful for your use case.

A simple approach could also be to have the locking/unlocking externally. Have a thread that checks process state, failure state, etc and changes the new table accordingly.