This is example of Jersey's Observable (RxJava) client extension using Netflix Hystrix latency and fault tolerant library.
The example extends official Jersey examples/rx-client-java8-webapp example.
For details see my Reactive Jersey Client using Java 8, RxJava and Netflix Hystrix blog post.
Run the example as follows:
mvn clean package jetty:run
This deploys current example using Jetty. You can access the application at:
- http://localhost:8080/rx/agent/sync
- http://localhost:8080/rx/agent/async<
- http://localhost:8080/rx/agent/listenable
- http://localhost:8080/rx/agent/observable
- http://localhost:8080/rx/agent/hystrix -- this one is new !
- http://localhost:8080/rx/agent/completion
- HystrixObservableAgentResource.java - Hystrix Observable JAX-RS Resource class
- RxClientsTest.java - unit test
testHystrixRxObservableClient
method. Focus onProcessingTime
assertion.
You can be sure the endpoint execution processing time is less than 950 milliseconds. This is because of using Hystrix with specified execution timeout. And that's the reason the response body is not sometimes complete, but on time.