The gateway microservice

First, we create a class that helps us deal with the responses:

public class GatewayResponse {    private String response;    private String from;    public String getResponse() {        return response;    }    public void setResponse(String response) {        this.response = response;    }    public String getFrom() {        return from;    }    public void setFrom(String from) {        this.from = from;    }}

Then, we create our gateway service:

@Consumes(MediaType.APPLICATION_JSON)@Path("gatewayResource")@RequestScopedpublic class GatewayResource {    private final String hostURI = "http://localhost:8080/";    private Client client;    private WebTarget targetUser;    private WebTarget targetAddress;    @PostConstruct    public void init() {        client = ClientBuilder.newClient(); targetUser ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.