Starting and running process instance within own asychronous method

Hi all,

I have a process definition with an exclusive Asynchronous Continuation right after the start event.

In my Java Application I start this process within an own asynchronous method (annotaded with the Spring @Async annotation). My asynchronous method will take 5 Minute to complete.

I now observe that the process instance is persited in Camunda right after the process start (because of the asynchronous continuation) but the following user tasks that I expect (the next wait state) is first reached (persisted) when my own asynchronous method finishes.

I am not sure why the system behaves like this. I probably has something to do with the fact that I start the Camunda process instance within an own long running async method. I guess it somehow conflicts with the Camunda Async execution (and transactional scope).

Do you have any idea how I can get over this? I need the process user tasks to be persisted when camunda reaches them. At the moment this happens first when my own async method finishes.

Kind regards,
Franz

Hi,

In the past, the default max wait time in the job executor used to default to about 5 minutes. Hence if there were no jobs to run, the executor job acquisition thread would go to sleep for up to 5 minutes. Thus could it be you are seeing this behaviour?

Consider setting maxWait to say 10000 or 10 seconds…

regards

Rob

Hi Rob,

I am not familiar with the concept of the job executor. What I see is that starting my process syncronous results in receiving (and persisting) the user-tasks nearly immediately whereas starting the process in an asyncronous method I have to wait for the user-tasks to be persisted until my asyncronous method finishes.

But I will have a look at the maxWait configuration of the job executor. Thanks.

Regards,
Franz

Hi Franz,

perhaps you could describe your application architecture - eg Spring boot, Spring App on shared engine, Tomcat or Jboss etc?

regards

Rob

Simple Spring Boot (using Camunda Spring Boot Starter) with embedded Camunda. I am using the Camunda Java API and finally start the process with

processEngine.getRuntimeService().startProcessInstanceByMessage

My use case:

I want to implement a “demo mode” where predefined messages will be used to start process instances at a given time. At the moment - if a 'demo" is started - an asny method is executed which will read the “demo configuration” and starts processes when expected (1/3/5 minutes after demo start). As the last message is processed 5 Minutes after the demo start the async methode also finishes after 5 minutes. Only then all the wait states of the processes are persisted.