org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider Java Examples
The following examples show how to use
org.glassfish.jersey.client.rx.rxjava2.RxFlowableInvokerProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlowableClient.java From ee8-sandbox with Apache License 2.0 | 5 votes |
public final static void main(String[] args) throws Exception { Client client = ClientBuilder.newClient(); client.register(RxFlowableInvokerProvider.class); WebTarget target = client.target("http://localhost:8080/jaxrs-async/rest/ejb"); target.request() .rx(RxFlowableInvoker.class) .get(String.class) .subscribe(new Subscriber<String>() { @Override public void onError(Throwable e) { System.out.println("onError:" + e.getMessage()); } @Override public void onNext(String t) { System.out.println("onNext:" + t); } @Override public void onSubscribe(Subscription s) { System.out.println("onSubscribe:" + s); s.request(1); } @Override public void onComplete() { System.out.println("onComplete"); } }); }
Example #2
Source File: RxJerseyClientFeature.java From rx-jersey with MIT License | 5 votes |
private Client defaultClient() { int cores = Runtime.getRuntime().availableProcessors(); ClientConfig config = new ClientConfig(); config.connectorProvider(new GrizzlyConnectorProvider()); config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, cores); config.register(RxFlowableInvokerProvider.class); return ClientBuilder.newClient(config); }
Example #3
Source File: RxJava2HttpBinService.java From spring-cloud-circuitbreaker-demo with Apache License 2.0 | 4 votes |
public RxJava2HttpBinService() { this.client = ClientBuilder.newClient(); this.client.register(RxObservableInvokerProvider.class); this.client.register(RxFlowableInvokerProvider.class); }
Example #4
Source File: RxJerseyBundle.java From rx-jersey with MIT License | 4 votes |
private Client getClient(Environment environment, JerseyClientConfiguration jerseyClientConfiguration) { return new JerseyClientBuilder(environment) .using(jerseyClientConfiguration) .using(new GrizzlyConnectorProvider()) .buildRx("rxJerseyClient", RxFlowableInvokerProvider.class); }
Example #5
Source File: ClientOrchestrationIntegrationTest.java From tutorials with MIT License | 4 votes |
@Test public void flowableJavaOrchestrate() throws InterruptedException { List<String> receivedHashValues = new ArrayList<>(); final CountDownLatch completionTracker = new CountDownLatch(expectedHashValues.size()); // used to keep track of the progress of the subsequent calls Flowable<List<Long>> userIdFlowable = getUserIdService().register(RxFlowableInvokerProvider.class).request().rx(RxFlowableInvoker.class).get(new GenericType<List<Long>>() { }); userIdFlowable.subscribe((List<Long> employeeIds) -> { logger.info("[FlowableExample] id-service result: {}", employeeIds); Flowable.fromIterable(employeeIds).subscribe(id -> { getNameService().register(RxFlowableInvokerProvider.class).resolveTemplate("userId", id).request().rx(RxFlowableInvoker.class).get(String.class) // gotten the name for the given userId .doOnError((throwable) -> { logger.warn("[FlowableExample] An error has occurred in the username request step {}", throwable.getMessage()); }).subscribe(userName -> { logger.info("[FlowableExample] name-service result: {}", userName); getHashService().register(RxFlowableInvokerProvider.class).resolveTemplate("rawValue", userName + id).request().rx(RxFlowableInvoker.class).get(String.class) // gotten the hash value for userId+username .doOnError((throwable) -> { logger.warn(" [FlowableExample] An error has occurred in the hashing request step!", throwable); }).subscribe(hashValue -> { logger.info("[FlowableExample] hash-service result: {}", hashValue); receivedHashValues.add(hashValue); completionTracker.countDown(); }); }); }); }); // wait for async calls to complete try { // wait for inner requests to complete in 10 seconds if (!completionTracker.await(10, TimeUnit.SECONDS)) { logger.warn("[CallbackExample] Some requests didn't complete within the timeout"); } } catch (InterruptedException e) { logger.error("Interrupted!", e); } assertThat(receivedHashValues).containsAll(expectedHashValues); }