Does anyone have a clue how to build a reactive rx java client using the client proxy? The official documentation: https://jersey.java.net/documentation/2.23.2/rx-client.html only provides examples with building an rxclient manually from WebTarget or client, which is extremely cumbersome (imagine adding query params in a loop) especially if you already have the resource interfaces created. Just passing the RxWebTarget to WebResourceFactory does not work.
Asked
Active
Viewed 441 times
2 Answers
0
ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.property(ClientProperties.PROXY_URI, "xxxx:xxxx");
Client client = JerseyClientBuilder.newClient(config);
return RxObservable.from(client).register(loggingFilter);

Bharath
- 1,787
- 1
- 20
- 37
-
I do not mean HttpProxy but a proxy Client made directly from the serverside jaxrs interface using the WebResourceFactory https://github.com/jersey/jersey/blob/master/ext/proxy-client/src/main/java/org/glassfish/jersey/client/proxy/WebResourceFactory.java – dziadeusz Nov 01 '17 at 13:02
0
Looking at version 2.26 WebResourceFactory source code, the Jersey proxy clients created by WebResourceFactory are not compatible with reactive client coding. These two lines of code invoke the call over the wire without any regards for the rx()
call that provokes the reactive style:
result = builder.method(httpMethod, Entity.entity(entity, contentType), responseGenericType);
} else {
result = builder.method(httpMethod, responseGenericType);
You might consider adding the ability as the WebResourceFactory class isn't terribly large or complicated.
Jersey 2.26 introduces the ability to assign an ExecutorService to your JerseyClient instance which you could then use to help manage concurrency by making calls to your your Jersey proxy clients from within Callable<> descendants.

jeffgzx9
- 269
- 1
- 6