use of com.google.cloud.pubsub.spi.v1.Subscriber in project google-cloud-java by GoogleCloudPlatform.
the class SubscriberSnippets method createSubscriberWithCustomCredentials.
private Subscriber createSubscriberWithCustomCredentials() throws Exception {
// [START pubsub_subscriber_custom_credentials]
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(new FileInputStream("credentials.json")));
ChannelProvider channelProvider = TopicAdminSettings.defaultChannelProviderBuilder().setCredentialsProvider(credentialsProvider).build();
Subscriber subscriber = Subscriber.defaultBuilder(subscriptionName, receiver).setChannelProvider(channelProvider).build();
// [START pubsub_subscriber_custom_credentials]
return subscriber;
}
Aggregations