Search in sources :

Example 11 with Subscriber

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;
}
Also used : Subscriber(com.google.cloud.pubsub.spi.v1.Subscriber) ChannelProvider(com.google.api.gax.grpc.ChannelProvider) FixedCredentialsProvider(com.google.api.gax.core.FixedCredentialsProvider) CredentialsProvider(com.google.api.gax.core.CredentialsProvider) FileInputStream(java.io.FileInputStream)

Aggregations

Subscriber (com.google.cloud.pubsub.spi.v1.Subscriber)7 PubsubMessage (com.google.pubsub.v1.PubsubMessage)4 Test (org.junit.Test)4 AckReplyConsumer (com.google.cloud.pubsub.spi.v1.AckReplyConsumer)3 ModifyAckDeadline (com.google.cloud.pubsub.spi.v1.FakeSubscriberServiceImpl.ModifyAckDeadline)3 MessageReceiver (com.google.cloud.pubsub.spi.v1.MessageReceiver)3 SubscriptionName (com.google.pubsub.v1.SubscriptionName)3 Publisher (com.google.cloud.pubsub.spi.v1.Publisher)2 TopicName (com.google.pubsub.v1.TopicName)2 FlowControlSettings (com.google.api.gax.batching.FlowControlSettings)1 CredentialsProvider (com.google.api.gax.core.CredentialsProvider)1 FixedCredentialsProvider (com.google.api.gax.core.FixedCredentialsProvider)1 ChannelProvider (com.google.api.gax.grpc.ChannelProvider)1 ExecutorProvider (com.google.api.gax.grpc.ExecutorProvider)1 InstantiatingExecutorProvider (com.google.api.gax.grpc.InstantiatingExecutorProvider)1 SubscriptionAdminClient (com.google.cloud.pubsub.spi.v1.SubscriptionAdminClient)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 FileInputStream (java.io.FileInputStream)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1