Posted: 25 Mar 2016 2:44 EDT Last activity: 16 Jun 2016 9:08 EDT
How to cancel locked assignment?
We have such requirement:
- a new assignment is assigned to an operator
- a request is came from other system to cancel the work object processing
- we need to close the work object and remove the assignment
Everything is fine if work object is not locked by operator.
But what can we do, if operator has opened his task already? He must not complete this task, because after this assignment there are some integration connectors. If they will be called, wrong information will go to other systems.
Here's how I suggest you find the right level of API to be using:
1) In two different browser sessions (make sure it's two different cookies, NOT just two tabs in one browser session!) try to open the same work object, and verify that the second one gives an error saying "work already locked, would you like to kill the other requestor to release the lock?"
2) Before clicking "yes", turn on the pega tracer.
3) Click "yes" and see what API is called for achieving the result.
Also test the case where your two requestors are logged in on different nodes from each other, keeping in mind that in this case, there is necessarily waiting involved, since the system pulse is used for alerting the other node to kill the requestor, and that can take up to an entire minute, depending on how long ago the pulse last ran.
1) For the unlock-requestor-on-other-node case, look at what API the other node uses to kill the requestor when it receives a request over the pulse. You could use the same API to kill whatever requestor you want.
2) You may be able to actually convince the existing pulse code to do your bidding for you if you generate a pulse request containing the requestor id you want to kill.
3) SMA has the ability to kill requestors, so you could look at what API it uses for killing them, and use the same API yourself.
Again, I'm afraid that I don't see a way to do this.
The engine code does contain override flags that you can use to remove a lock from a different requester. However, this won't allow you to remove the lock if it is a different operator.
If you trace the SQL that is generated to remove the lock, or set the logging level to DEBUG on com.pega.pegarules.data.internal.access.DBLockProviderImpl, then you should see that this is only trying to remove the lock if you are the owner.
And as you've already discovered simply removing the record from PR_SYS_LOCKS won't work due to the Lock Cache.
Sorry I don't have more promising news in this instance.