i am using camunda REST i would like to know whats the best way to work with task / process Instance assignments. There is a REST call that assigns a single task to a user but after submitting the task the assignment is lost.
My goal is to assign the complete process Instance to a person. But i am not sure if this rly makes sense or not and if yes then how ?
If this is not possible or doesnt make sense, how would you handle the fact that after submitting a task the assignment is lost ? Would you reassign every time the next task?
Thank you
It could totally make sense to assign all user tasks of a process to a specific user or group.
You could model this in the bpmn by setting the assignee to a variable (${assignee}) and then just set this variable once on the process instance. All tasks then are automatically assigned to the user named in the variable.
Related
I can now start a new BPMN process using the REST API. What I did notice is that I do not set the Instance ID. I get that value in the return. Is it possible to set the ID ? We use that as the primary key on other places. So I would like to be able to tell the BPMN what ID to use for the instance of the process. It seems I am getting random numbers coming back.
OK so it seems you can set the BusinessKey to a value that you know end search with it. So it is similar to what I what.
ENV: Camunda 7.5
Approach: Single Process Engine With Tenant-Identifiers with Transparent Access Restrictions for Tenants
Given: foo is a process definition key which is deployed without tenant ID, i.e. shared process among all tenants. bar is the ID of a service task within foo.
The TenantIdProvider works well if one start process instances normally (startXXX or startXXXByMessage). For test cases which don't start process instances this way, rather with:
runtimeService.createProcessInstanceByKey('foo')
.startBeforeActivity('bar')
.execute()
the tenant ID doesn't get set. Maybe someone can point out why and how. Thanks!
Not implemented yet. See also: https://app.camunda.com/jira/browse/CAM-6218
I have a requirement where a user could be assigned thousands (1000 - 5000) tasks, belonging to different process instances (same user task from 1000 - 5000) instances at a given time. I have a custom task list screen where I need to load all the tasks with their basic info (id, name, process instance id etc) and some process variables for each.
First I used the filter/list REST service i.e. engine-rest/filter/{filter-id}/list to get the tasks with the process variables. (I created a filter in Camunda tasklist). But this REST service takes forever to return when there are more than 1000 process instances in question. It took 7-8 mins for about 2000 process instances. Maybe because this service returns a lot of information which I don't need.
So I decided to write my own REST service using Camunda Java api. This is what I did -
List<Task> tasks = taskService.createTaskQuery().processDefinitionKey(processDefinitionKey).taskAssignee(assignee).list();
if(tasks != null && !tasks.isEmpty()){
for(Task task : tasks){
.....
.....
Map<String, Object> variables = taskService.getVariables(task.getId(), variableNames);
.....
}}
This works and is much faster than the filter service. But for about 1000 instances it is taking around 25 secs. (My server is not production grade right now, Tomcat Xms -1gb Xmx - 2gb).
But my concern is that internally is this code hitting the DB 1000 times (for each tasks returned by taskquery) to get the variables? Worse still depending on the number of variables is it querying the DB that many times for each variable? I mean for 5 variables are we hitting the DB 5000 times?
1) If so, is there any way I can improve this service? Like can I write a NativeTaskQuery where I join the act_ru_task, act_ru_process & act_ru_variable tables to get the data I need? Is that the right way?
2) Isn't there any inbuilt caching in Camunda that can help here?
Thanks in advance for your help.
You can use a custom query for this. Write your native sql query and add a mybatis mapping. This example explains the concept : https://github.com/camunda-consulting/code/tree/master/snippets/custom-queries
I use camunda 7.2.0 and i'm not very experienced with it. I'm trying to write data about users, who had done something with process instance to database (i'm using rest services) to get some kind of reports later. The problem is that i don't know how to trigger my rest(that sends information to datebase about current user and assignee) when user assignes task to somebody else or claims task to himself. I see that camunda engine sends request like
link: engine/engine/default/task/5f965ab7-e74b-11e4-a710-0050568b5c8a/assignee
post: {"userId":"Tom"}
As partial solution I can think about creating a global variable "currentUser" and on form load check if user is different from current, and if he is - run the rest and change variable. But this solution don't looks correct to me. So is there any better way to do it? Thanks in advance
You could use a task listener which updates your data when the assignee of a task is changed. If you want this behavior for every task you could define a global task listener.
In django-webtest, every test TestCase subclass comes with self.app, which is an instance of webtest.TestApp, then I could make it login as user A by self.app.get('/',user='A').
However, if I want to test the behavior if for both user A and user B in a test, how should I do it?
It seems that self.app is just DjangoTestApp() with extra_environ passed in. Is it appropriate to just create another instance of it?
I haven't tried setting up another instance of DjangoTestApp as you suggest, but I have written complex tests where, after making requests as user A I have then switched to making requests as user B with no issue, in each case passing the user or username in when making the request, e.g. self.app.get('/', user'A') as you have already written.
The only part which did not work as expected was when making unauthenticated requests, e.g. self.app.get('/', user=None). This did not work as expected and instead continued to use the user from the request immediately prior to this one.
To reset the app state (which should allow you to emulate most workflows with several users in a sequential manner) you can run self.renew_app() which will refresh your app state, effectively logging the current user out.
To test simultaneous access by more than one user (your question does not specify exactly what you are trying to test) then setting up another instance of DjangoTestApp would seem to be worth exploring.