April 2018
Intermediate to advanced
382 pages
10h 11m
English
We start the bean by creating the communication with the remote endpoint right in the bean instantiation. Doing this will avoid the overhead of doing it later while the invocation is happening:
private Client client;private WebTarget target;@PostConstructpublic void init() { client = ClientBuilder.newBuilder() .readTimeout(10, TimeUnit.SECONDS) .connectTimeout(10, TimeUnit.SECONDS) .build(); target = client.target("http://localhost:8080/ ch10-async-jaxrs/remoteUser");}
Then, we created an anonymous InvocationCallback implementation within our async invoker:
target.request().async().get(new InvocationCallback<Response>() { @Override public void completed(Response rspns) { response.resume(rspns); } @Override public void failed(Throwable ...Read now
Unlock full access