AnsweredAssumed Answered

Executing Async task in not working

Question asked by mohitsrivastava on Oct 9, 2015
Latest reply on Oct 16, 2015 by mohitsrivastava
Hi,

I am trying to execute an async task. But it is not running.

My requirement is servicetask2 should execute while servicetask1 is still in progress.

I did the following. Please have a look at the files I used.:

1. BPMN File(Only relevant part shown):

  <process id="Async" name="Async" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="AsyncProcess" activiti:async="true" activiti:class="com.demo.JavaAsyncTask"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <serviceTask id="servicetask2" name="NormalProcess" activiti:class="com.demo.JavaNormalTask"></serviceTask>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="servicetask2"></sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="servicetask2" targetRef="endevent2"></sequenceFlow>
  </process>

2. Java class 1:

public class JavaAsyncTask implements JavaDelegate{
   public void execute(DelegateExecution execution) throws Exception {
      System.out.println("Java Async Task Started");
      Thread.sleep(60000);
      System.out.println("Java Async Task End");
   }
}

3.Java Class 2:

public class JavaNormalTask implements JavaDelegate{
   public void execute(DelegateExecution execution) throws Exception {
      System.out.println("Java Normal Task Started");
      System.out.println("Java Normal Task End");
   }
}


4. I created jar and copied in lib directory of tomcat.

5. Now on doing Start Process in Activiti Explorer Nothing happens. Nothing is displayed in log(catalina.out)

6. But when I removed activiti:async="true" from BPMN file. Then the values specified in system.out are displayed in log.

So could you please suggest how to use this async=true. Any more configuration is required?

Thanks and Regards
Mohit Srivastava

Outcomes