use of com.google.api.gax.core.InstantiatingExecutorProvider in project google-cloud-java by GoogleCloudPlatform.
the class PubsubBenchWrapperImpl method recv.
public void recv(PubsubRecv request, StreamObserver<EmptyResponse> responseObserver) {
System.out.println("recv has been called");
ProjectSubscriptionName subscriptionName = ProjectSubscriptionName.of("some-project", request.getSubName());
Subscriber subscriber = null;
try {
InstantiatingExecutorProvider executorProvider = InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(1).build();
subscriber = Subscriber.newBuilder(subscriptionName, new SimpleReceiver()).setExecutorProvider(executorProvider).build();
subscriber.startAsync().awaitRunning();
// Allow the subscriber to run indefinitely unless an unrecoverable error occurs.
subscriber.awaitTerminated();
} catch (IllegalStateException e) {
System.out.println("Subscriber unexpectedly stopped: " + e);
}
EmptyResponse reply = EmptyResponse.newBuilder().build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
Aggregations