-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not delete candidate user defined in BPMN with task's creation listener #4846
Comments
Hi @tonny1983, Thanks for opening this issue. A workaround would be to create the candidate user in the listener and commit that to the database (e.g., have a transaction boundary). In another activity, delete the candidate user again. The taskService (and other services) API works by interacting with the database. While it is technically possible to make it look for entities in the persistence cache, this would complicate the API calls a lot and would introduce other problems. For example, should the creation and deletion of the candidate user leave traces in the operation logs? I don't think that this behavior is a bug and this issue should rather be a feature request. What do you think? Let me know what you think. |
Hi @mboskamp , Thanks a lot for your kind reply. In fact, the issue is mainly based on the different behaviours between add/remove identity links and variables in the task listener. task.setVariable("key1","value1");
task.removeVariable("key1");
var runtimeService = task.getProcessEngineServices().getRuntimeService();
runtimeService.setVariable(task.getProcessInstanceId(), "key2", "value2");
runtimeService.removeVariable(task.getProcessInstanceId(), "key2"); The var variableCount = runtimeService().createVariableInstanceQuery().count();
Assertions.assertEquals(0, variableCount); By comparing the behaviour of
With full respect for different opinions, I'm afraid that this difference contains at least a bug there and I chose the behaviour of deleting candidate user because in mu opinion that the query before delete is unnecessory (deleting a non-existent entity in db seems no harmful effects). Thank you for your time and I'm awaiting your futher response. |
Environment
Camunda BPM Engine v7.22.0
Description
Candidate uers which is defined in BPMN model can not be removed in its task's creation listener with
TaskService#deleteCandidate
method.Steps to reproduce
abcdefg
:camunda-bpm-assert
Observed Behavior
Both
taskService().createTaskQuery().taskCandidateUser("abcdefg").count()
andtaskService().createTaskQuery().taskCandidateUser("abc").count()
returns value of1
.Expected behavior (Required on creation)
There should be no tasks the candidate user of which is "abcdefg" or "abc".
Root Cause
I'm not sure whether the problem related to the
IdentityLinkManager#findIdentityLinkByProcessDefinitionUserAndGroup
method which calls theselectIdentityLinkByTaskUserGroupAndType
. In the method, itgetDbEntityManager
method to excute the sql.As the
INSERT
sql ofIdentityLinkEntity
is obviously behind of thisSELECT
sql (shows in the following log), there are really no such a DB entity in the SQL transaction. However, the entity should exist in the persistence cache and could be retrieved.Solution Ideas
Try to retrieve the
IdentityLinkEntity
from persistence cache first ???Hints
Here is the detail console log about the process
It seems that
TaskService#deleteCandidate
method firstly callsselectIdentityLinkByTaskUserGroupAndType
SQL to check whether theIdentityLinkEntity
exists or not. TheAddUserIdentityLinkCmd
andDeleteUserIdentityLinkCmd
reuse the same existing command context as the log shows, theIdentityLinkEntity
should exists not in fact the result ofselectIdentityLinkByTaskUserGroupAndType
is 0.The text was updated successfully, but these errors were encountered: