Calling REST service from java delegate async

Hi

I want to call an external REST service from a Task via java delegate. I want to call the REST service async with CompletableFuture.

Is there any examples of this? Or a recommended way to do it?

Hello
So you have a ServiceTask, which you are going to process using JavaDelegate (calling REST service).
It is not clear what are you going to achive with async functionality.

Hi

There could be several/many different calls to underlying systems which we would like to call in parallell. I think the most important future is the future functionality.

The async is a requirement.

At the example below I assume you have your REST/HTTP sync calls as “yourRestApiClient.” As alternative you can use a http/rest client, that supports CompletableFuture.

CompletableFuture.allOf(
     CompletableFuture.supplyAsync(() -> yourRestApiClient.getMethod1(someParams1),
     CompletableFuture.supplyAsync(() -> yourRestApiClient.getMethod2(someParams2),
    CompletableFuture.supplyAsync(() -> yourRestApiClient.getMethod3(someParams3)
).join();

Hi Frank,

I am not sure if it will fit your needs but it worth mention that Camunda offers Asynchronous Continuations:
https://docs.camunda.org/manual/7.10/user-guide/process-engine/transactions-in-processes/#asynchronous-continuations