cancel
Showing results for 
Search instead for 
Did you mean: 

AbstractBpmnActivityBehavior example for long tasks process

marcantoine
Champ in-the-making
Champ in-the-making
Hi,

I starting using some specific features of Activiti.
The deal is to create a task which can send to a web service an order to start a long task (like media encoding, or big size file transfer etc.).
And he end of the task will be signalized by the web service to activiti with based on a callback message.

I found some documentation about that on Camunda: https://github.com/camunda/camunda-bpm-examples/tree/master/servicetask/service-invocation-asynchron...
Is it also available into Activiti ? Do you have some examples to test this work around ?
I start to adapt he Camunda code for Activiti but it don't work.

Thanks
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Marc-Antoine,

I would say you need to invoke web service and web service needs to notify process instance to continue in execution.
I think you have implemented web service call already. The only missing thing is how to put process instance into wait state and notify it to continue in execution.
Following example (activiti source) could help you:

  @Deployment
  public void testWaitStateBehavior() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
    Execution execution = runtimeService.createExecutionQuery()
      .processInstanceId(pi.getId())
      .activityId("waitState")
      .singleResult();
    assertNotNull(execution);
   
    runtimeService.signal(execution.getId());
    assertProcessEnded(pi.getId());
  }

Regards
Martin

marcantoine
Champ in-the-making
Champ in-the-making
Okay it work fine for the unit test !
But for the runtime, which URI I need to call from my webservice to emit the signal ? Is it mentionned in he REST API of Activiti (I never use it…) ?

martin_grofcik
Confirmed Champ
Confirmed Champ

marcantoine
Champ in-the-making
Champ in-the-making
Hi Martin,

I have tested the solution but if I understand, I need to create a serviceTask to send the order to my web service (in asynchronous mode). And adding after that a receiveTask to get the callback of the process.

There are no way to do that in a single "serviceTask" task ?

Thanks,

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Marc-Antoine,
There are no way to do that in a single "serviceTask" task ?

Possibilities:
  1. Design process with send -> receiveTask and call it from the parent process (callActivity)
  2. Implement your own service which can make these two steps in one. (You can extend designer to support your custom tasks.)
Which one you prefer depends on your requirements.

Regards
Martin