December 2019
Intermediate to advanced
314 pages
6h 51m
English
To include a distributed peer-to-peer messaging pattern in our application, we will need to inject the EventBus instance into a CDI bean, which will act as a receiver:
@Inject EventBus bus;
In our case, we will add the EventBus to the CustomerEndpoint class.
Now, in the same class, let's create a new endpoint method, which will be in charge of dispatching messages:
@GET@Path("/call")@Produces("text/plain")public CompletionStage<String> call(@QueryParam("id") Integer customerId) { return bus.<String>send("callcustomer", customerRepository.findCustomerById(customerId)) .thenApply(Message::body) .exceptionally(Throwable::getMessage) ...
Read now
Unlock full access