samedi 4 janvier 2020

Sequence of Rest and Soap calls to get the final result using Spring Boot 2

I have to make a sequence of calls like a chain to other microservices to get the final result.

Of these calls, some are SOAP and some REST.

Is there any good design pattern to chain these calls and handle exceptions using synchronous.

If I go with Asynchronous then CompletableFuture chain will be the right choice for SOAP calls?

For example

 CompletableFuture.supplyAsync(() -> getEmp())
    .thenApply(emp -> {
        // handle soap client call
        return soapClientService.getDepartmentResponse();
    })
    .thenApply(dept -> {            
        return restTemplateService.getRestDeptAPICalls();
    })
    .handle((result, exception) -> {
        // handle exception and result
    });

Aucun commentaire:

Enregistrer un commentaire