Reputation: 2570
I'm creating task using TaskService using below snippet.
Task task = taskService.newTask();
task.setName(taskName);
task.setParentTaskId(taskParentId);
task.setDescription(taskDescription);
task.setCategory(taskCategory);
taskService.saveTask(task);
I have got a requirement where I need to create multiple tasks(1000) but taskService.saveTask() is taking too much time to create these many tasks. Tried exploring the Activiti APIs but couldn't find any API related to bulk task creation. Does Activiti support bulk task creation? If not, can someone share an alternate to handle this scenario?
Upvotes: 1
Views: 420
Reputation: 1343
You could use multiple Threads to create the tasks.
ExecutorService pool = Executors.newFixedThreadPool(1000);
for(int i=0;i<1000;i++)
{
pool.execute(()->
{
Task task = taskService.newTask();
task.setName(taskName);
task.setParentTaskId(taskParentId);
task.setDescription(taskDescription);
task.setCategory(taskCategory);
taskService.saveTask(task);
});
}
Upvotes: 1