AnsweredAssumed Answered

Suggest the Best Approach in using Activiti for the workflow

Question asked by chandanmb1 on Jun 30, 2016
Latest reply on Jul 1, 2016 by hari
Hello All,

Let me explain my use case in simple terms.
I have multiple workflows created by multiple user.
One example of a workflow is

    Start  —–> JiraService —–> ClearQuest Service —>……—> n—-> End

When the user clicks start

I am starting with startProcessInstance


   public ProcessInstance startProcess(String productLine, Map<String, Object> processVariables, String comment)  {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("almAdminPro", processVariables);
        taskService.addComment(null, processInstance.getId(), "test");
        return processInstance;
   }

My assumption is
I will check what is the current service to be executed from ACT_RU_TASK by querying using taskService.
I will get to know what is the current task, according to the above workflow it is JiraService.

So, i will call my custom class to create JiraService and perform some operation. Based on the response from JiraService. I will complete the current task.

   public void completeTask(Map<String, Object> taskVariables, String processInstanceId, String currentApprover)  {
      
      Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskAssignee(currentApprover).singleResult();
      if(task != null) {
         taskService.complete(task.getId(), taskVariables);
      }
   }


Next it will move to next Service so on..
Questions:

1. Is the above approach works ?
2. Sometimes JiraService may execute for days.At that time what happens to activiti instance thread. Because i may have lot of workflows like this. Should i suspend the thread and make it active once response come from JiraService and complete? or Shall i leave as is and once response come from JiraService and complete?
3. How is the threadManagement handle internally in community edition?
4. Also, sometips to handle complex scenarios if i have missed out in asking the above scenario.

Thanks for reading. Please help!

Outcomes