Add files via upload
This commit is contained in:
parent
c195c5dc50
commit
075ba76de1
|
@ -6,6 +6,11 @@
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.inject</groupId>
|
||||||
|
<artifactId>jersey-hk2</artifactId>
|
||||||
|
<version>2.27</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.core</groupId>
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
<artifactId>jersey-client</artifactId>
|
<artifactId>jersey-client</artifactId>
|
||||||
|
|
|
@ -28,9 +28,9 @@ import rx.Observable;
|
||||||
public class ClientOrchestration {
|
public class ClientOrchestration {
|
||||||
|
|
||||||
Client client = ClientBuilder.newClient();
|
Client client = ClientBuilder.newClient();
|
||||||
WebTarget userIdService = client.target("http:localhost:8080/serviceA/id?limit=10");
|
WebTarget userIdService = client.target("http://localhost:8080/serviceA/id?limit=10");
|
||||||
WebTarget nameService = client.target("http:localhost:8080/serviceA/{empId}/name");
|
WebTarget nameService = client.target("http://localhost:8080/serviceA/{empId}/name");
|
||||||
WebTarget hashService = client.target("http:localhost:8080/serviceA/{comboIDandName}/address");
|
WebTarget hashService = client.target("http://localhost:8080/serviceA/{comboIDandName}/address");
|
||||||
|
|
||||||
Logger logger = Logger.getLogger("ClientOrchestrator");
|
Logger logger = Logger.getLogger("ClientOrchestrator");
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ public class ClientOrchestration {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed(Throwable throwable) {
|
public void failed(Throwable throwable) {
|
||||||
completionTracker.countDown();
|
completionTracker.countDown();
|
||||||
|
@ -80,7 +81,7 @@ public class ClientOrchestration {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!completionTracker.await(10, TimeUnit.SECONDS)) { //wait for inner requests to complete in 10 seconds
|
if (!completionTracker.await(10, TimeUnit.SECONDS)) { //wait for inner requests to complete in 10 seconds
|
||||||
logger.warning("Some requests didn't complete within the timeout");
|
logger.warning("Some requests didn't complete within the timeout");
|
||||||
|
@ -88,7 +89,7 @@ public class ClientOrchestration {
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(ClientOrchestration.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ClientOrchestration.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,12 +110,8 @@ public class ClientOrchestration {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
CompletionStage<List<CompletionStage<String>>> completedNameStage = userIdStage.thenApplyAsync(list -> list.stream().map((Long id) -> {
|
|
||||||
CompletionStage nameStage = nameService.resolveTemplate("empId", id).request().rx().get(String.class);
|
|
||||||
}).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
userIdStage.thenAcceptAsync(listOfIds -> {
|
userIdStage.thenAcceptAsync(listOfIds -> {
|
||||||
listOfIds.stream().map((Long id) -> {
|
listOfIds.stream().forEach((Long id) -> {
|
||||||
CompletableFuture<String> completable = nameService.resolveTemplate("empId", id)
|
CompletableFuture<String> completable = nameService.resolveTemplate("empId", id)
|
||||||
.request()
|
.request()
|
||||||
.rx()
|
.rx()
|
||||||
|
@ -143,10 +140,7 @@ public class ClientOrchestration {
|
||||||
public void observableJavaOrchestrate() {
|
public void observableJavaOrchestrate() {
|
||||||
|
|
||||||
logger.info("Orchestrating with Observables");
|
logger.info("Orchestrating with Observables");
|
||||||
|
Observable<List<Long>> userIdObservable = userIdService.register(RxObservableInvokerProvider.class).request()
|
||||||
client.register(RxObservableInvokerProvider.class);
|
|
||||||
|
|
||||||
Observable<List<Long>> userIdObservable = userIdService.request()
|
|
||||||
.rx(RxObservableInvoker.class)
|
.rx(RxObservableInvoker.class)
|
||||||
.get(new GenericType<List<Long>>() {
|
.get(new GenericType<List<Long>>() {
|
||||||
});
|
});
|
||||||
|
@ -173,10 +167,7 @@ public class ClientOrchestration {
|
||||||
public void flowableJavaOrchestrate() {
|
public void flowableJavaOrchestrate() {
|
||||||
|
|
||||||
logger.info("Orchestrating with Flowable");
|
logger.info("Orchestrating with Flowable");
|
||||||
|
Flowable<List<Long>> userIdObservable = userIdService.register(RxFlowableInvokerProvider.class).request()
|
||||||
client.register(RxFlowableInvokerProvider.class);
|
|
||||||
|
|
||||||
Flowable<List<Long>> userIdObservable = userIdService.request()
|
|
||||||
.rx(RxFlowableInvoker.class)
|
.rx(RxFlowableInvoker.class)
|
||||||
.get(new GenericType<List<Long>>() {
|
.get(new GenericType<List<Long>>() {
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue