I've been working on a Java microservice that uses Reactor in order to make asynchronous calls easier. On my endpoint I have the following code:
@HystrixCommand
@ApiOperation(value = "Resolve Dispute")
@PostMapping(consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE, path = "/resolve")
public Mono<RestResponse<RestResponseResult>> resolveDispute(@RequestBody ResolveDisputeRequest requestJson, @RequestParam("appToken") String appToken) {
if (apiAppToken.equals(appToken)) {
EnumsUtils.getEnumValue(DisputeReason.values(), requestJson.getResolutionType(), requestJson);
return facebookApiService.resolveDispute(requestJson).single();
} else {
throw new InvalidTokenException(requestJson.getUserId());
}
}
Which I would expect to return an object
{
result: true/false
}
However, as I inspect the code, I realize that a response is issued before the code finishes its' process. The response given is:
{
"scanAvailable": true
}
Which leads me to believe that this has to do with the asynchronous nature of Reactor, but doesn't suit my needs.
How should I properly use Reactor in order to obtain the required response? I do not wish to use block method which makes the call blocking.
Thanks in advance for any provided help.
All the best,
Alejandro