cancel
Showing results for 
Search instead for 
Did you mean: 

Suggest the Best Approach in using Activiti for the workflow

chandanmb1
Champ on-the-rise
Champ on-the-rise
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!
1 REPLY 1

hari
Star Contributor
Star Contributor
Hi,

You need to check for whats the next activity. When you complete the current activity it automatically moves to the next one.
If the JIRA service takes days, no issues, you may use an asynchronous call here.