use of com.google.api.gax.grpc.ExecutorProvider in project google-cloud-java by GoogleCloudPlatform.
the class PublisherSnippets method getSingleThreadedPublisher.
public Publisher getSingleThreadedPublisher(TopicName topicName) throws Exception {
// [START pubsub_publisher_single_threaded]
// create a publisher with a single threaded executor
ExecutorProvider executorProvider = InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(1).build();
Publisher publisher = Publisher.defaultBuilder(topicName).setExecutorProvider(executorProvider).build();
// [END pubsub_publisher_single_threaded]
return publisher;
}
use of com.google.api.gax.grpc.ExecutorProvider in project google-cloud-java by GoogleCloudPlatform.
the class SubscriberSnippets method createSingleThreadedSubscriber.
private Subscriber createSingleThreadedSubscriber() throws Exception {
// [START pubsub_subscriber_single_threaded]
// provide a separate executor service for polling
ExecutorProvider executorProvider = InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(1).build();
Subscriber subscriber = Subscriber.defaultBuilder(subscriptionName, receiver).setExecutorProvider(executorProvider).build();
// [END pubsub_subscriber_single_threaded]
return subscriber;
}
Aggregations