Variables Performance
andre.muniz Mar 25, 2010 2:32 PMHi!
My use case is very simple: I need to load all the pending tasks and show information about them (including variables). But I'm having some performance problems when loading those variables.
Basically my code is like this:
// Builds the process engine ProcessEngine processEngine = new Configuration().buildProcessEngine(); // Creates the services TaskService taskService = processEngine.getTaskService(); ExecutionService executionService = processEngine.getExecutionService(); // Loads all the pending tasks List < Task > tasks = taskService.createTaskQuery().list(); // Loads the variables for each task for (Task t : tasks) { // Variable names Set < String > variableNames = new TreeSet < String >(); variableNames.add("var1"); variableNames.add("var2"); variableNames.add("var3"); variableNames.add("var4"); variableNames.add("var5"); // Loads the variables Map < String, Object > variables = executionService.getVariables(t.getExecutionId(), variableNames); // Shows variables information System.out.println(variables); }
The "taskService.createTaskQuery().list()" method is very fast, but the processing time to load the variables is very high. I'm running some scalability tests, and I realized that the code I've just mentioned is causing a lot of hard disk access (which is causing the performance problems), so I wonder if there is another way of writing this code.
My question is:
Am I going in the right direction or there is another way to implement this use case with better performance?
PS: I've seen the JIRA request to include searching for process instances by variables (https://jira.jboss.org/jira/browse/JBPM-2505) and there are some comments about variable performance, but I'm not sure that in my use case I should have this kind of problem.
Thanks!