Hello,
I’m trying to understand which way is the best or if there’s something i can’t make work ok.
Supposing I have this Spring Web Controller POST method:
`
@POST
@Path("/update")
public Response handle(UpdateJobCategoryPayload payload) {
FutureCallback<UpdateJobCategory, Void> cb = new FutureCallback<>();
commandBus.dispatch(asCommandMessage(payload.asCommand()), cb);
if (cb.isDone()) {
try {
cb.get();
} catch (ExecutionException e) {
return Response.status(Status.NOT_FOUND).build();
}
return Response.ok().build();
}
return Response.serverError().build();
}
`
When CommandHandler fails, no exception has been thrown. So I tried to handle it async and inspecting class hierarchy I found this FutureCallback<C, R>. Changing the domain code and now I’m able to catch an ExecutionException I can inspect to get if the AggregateKey is not found.
The documentation lacks of some information to understand if I wrote my code ok! Can you please provide your ideas?
This code smells very very much.
TIA!