AnsweredAssumed Answered

TaskQuery missing .variableValueEquals()

Question asked by thomas1 on Jan 6, 2011
Latest reply on Feb 7, 2011 by frederikheremans1

I started evaluating Activiti and I am quite impressed. It was very easy to write an example workflow and use the API, straight foward, very nice, thanks for the execellent work.

I implemented a simple order management with these nodes:
Start -> UserTask -> ServiceTask -> End
The UserTask sets a variable that decides if the order goes to the ServiceTask or to an EndError node, this works fine so far.

Concerning performance I am stuck at the moment because my TaskQuery is way too slow. I am not sure if I misuse Activiti or if a feature is missing.

When I start the workflow I set a variable "department" = "dep1". This way I started 100.000 Workflows for 500 different departments - this was very fast as well.

To get the tasks I do the following at the moment:

TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.taskName("Allow order");
List<Task> taskList = taskQuery.list();

for (Task task : taskList) {
   Map<String, Object> variables = taskService.getVariables(task.getId());
   final String taskDepartment = (String)variables.get("department");
   if (taskDepartment.matches("dep1")) {

Obviously this runs forever. 100.000+1 SQL Queries are executed, then I have to throw away 99.800 of the results.

Querying the process instances on the other hand is very fast:
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
query.variableValueEquals("department", "dep1");
rc = query.list();

So this should be possible for Tasks as well?