# Cloud Pub/Sub v1 API - Class SubscriberClientBuilder (3.36.0)

3.36.0 (latest) 3.35.0 3.34.0 3.33.0 3.32.0 3.31.0 3.30.0 3.29.0 3.28.0 3.27.0 3.26.0 3.25.0 3.24.0 3.23.0 3.22.0 3.21.0 3.20.0 3.19.0 3.18.0 3.17.0 3.16.0 3.15.0 3.14.0 3.13.0 3.12.0 3.11.0 3.10.1 3.9.1 3.8.0 3.7.0 3.6.0 3.5.1 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0

    public sealed class SubscriberClientBuilder : ClientBuilderBase<SubscriberClient>

Reference documentation and code samples for the Cloud Pub/Sub v1 API class SubscriberClientBuilder.

Builder class for [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) to provide simple configuration of credentials,
endpoint, client count, subscription settings etc.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [ClientBuilderBase](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html)[SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) \> SubscriberClientBuilder

## Inherited Members

[ClientBuilderBase\<SubscriberClient\>.Build(IServiceProvider)](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_Build_System_IServiceProvider_) [ClientBuilderBase\<SubscriberClient\>.BuildAsync(IServiceProvider, CancellationToken)](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_BuildAsync_System_IServiceProvider_System_Threading_CancellationToken_) [ClientBuilderBase\<SubscriberClient\>.UniverseDomain](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_UniverseDomain) [ClientBuilderBase\<SubscriberClient\>.Endpoint](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_Endpoint) [ClientBuilderBase\<SubscriberClient\>.Logger](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_Logger) [ClientBuilderBase\<SubscriberClient\>.Scopes](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_Scopes) [ClientBuilderBase\<SubscriberClient\>.ChannelCredentials](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_ChannelCredentials) [ClientBuilderBase\<SubscriberClient\>.CredentialsPath](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_CredentialsPath) [ClientBuilderBase\<SubscriberClient\>.JsonCredentials](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_JsonCredentials) [ClientBuilderBase\<SubscriberClient\>.GoogleCredential](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_GoogleCredential) [ClientBuilderBase\<SubscriberClient\>.Credential](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_Credential) [ClientBuilderBase\<SubscriberClient\>.TokenAccessMethod](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_TokenAccessMethod) [ClientBuilderBase\<SubscriberClient\>.CallInvoker](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_CallInvoker) [ClientBuilderBase\<SubscriberClient\>.UserAgent](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_UserAgent) [ClientBuilderBase\<SubscriberClient\>.GrpcAdapter](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_GrpcAdapter) [ClientBuilderBase\<SubscriberClient\>.ApiKey](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_ApiKey) [ClientBuilderBase\<SubscriberClient\>.QuotaProject](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_QuotaProject) [ClientBuilderBase\<SubscriberClient\>.GrpcChannelOptions](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_GrpcChannelOptions) [ClientBuilderBase\<SubscriberClient\>.LastCreatedChannel](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_LastCreatedChannel) [ClientBuilderBase\<SubscriberClient\>.UseJwtAccessWithScopes](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_UseJwtAccessWithScopes) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.PubSub.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1)

## Assembly

Google.Cloud.PubSub.V1.dll

## Constructors

### SubscriberClientBuilder()

    public SubscriberClientBuilder()

Creates a new instance with default settings. [TopicName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.TopicName) must be set
before calling either [Build()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientBuilder#Google_Cloud_PubSub_V1_SubscriberClientBuilder_Build) or [BuildAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientBuilder#Google_Cloud_PubSub_V1_SubscriberClientBuilder_BuildAsync_System_Threading_CancellationToken_).

## Properties

### ApiSettings

    public SubscriberServiceApiSettings ApiSettings { get; set; }

The settings to use when creating[SubscriberServiceApiClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberServiceApiClient) instances.
Default settings will be used if this is null.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberServiceApiSettings` |   |

### ClientCount

    public int? ClientCount { get; set; }

The number of [SubscriberServiceApiClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberServiceApiClient)s to create and use within a [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) instance.
If this is null, the number of clients created will depend on the processor count.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### EmulatorDetection

    public EmulatorDetection EmulatorDetection { get; set; }

Specifies how to respond to the presence of emulator environment variables.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.EmulatorDetection.html` |   |

**Remarks** This property defaults to [None](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.EmulatorDetection.html#Google_Api_Gax_EmulatorDetection_None), meaning that
environment variables are ignored.

### Settings

    public SubscriberClient.Settings Settings { get; set; }

Additional settings for batching, message ordering etc. Default settings will be used if this is null.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Settings` |   |

### ShareClientConnections

    public bool ShareClientConnections { get; set; }

Whether the [PublisherServiceApiClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.PublisherServiceApiClient)s may share gRPC connections or not.
Defaults to false, meaning, each client has its own gRPC connection.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### SubscriptionName

    public SubscriptionName SubscriptionName { get; set; }

The name of the subscription that the subscriber subscribes to.
This must be non-null by the time [Build()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientBuilder#Google_Cloud_PubSub_V1_SubscriberClientBuilder_Build) or [BuildAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientBuilder#Google_Cloud_PubSub_V1_SubscriberClientBuilder_BuildAsync_System_Threading_CancellationToken_) is called.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriptionName` |   |

## Methods

### Build()

    public override SubscriberClient Build()

Builds the resulting client.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient` |   |

**Overrides** Google.Api.Gax.Grpc.ClientBuilderBase\<Google.Cloud.PubSub.V1.SubscriberClient\>.Build()

### BuildAsync(CancellationToken)

    public override Task<SubscriberClient> BuildAsync(CancellationToken cancellationToken = default)

Builds the resulting client asynchronously.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient` |   |

**Overrides** Google.Api.Gax.Grpc.ClientBuilderBase\<Google.Cloud.PubSub.V1.SubscriberClient\>.BuildAsync(System.Threading.CancellationToken)

### GetChannelPool()

    protected override ChannelPool GetChannelPool()

Returns the channel pool to use when no other options are specified. This method is not called unless
[CanUseChannelPool](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_CanUseChannelPool) returns true, so if a channel pool is unavailable, override that property
to return false and throw an exception from this method.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ChannelPool.html` |   |

**Overrides** Google.Api.Gax.Grpc.ClientBuilderBase\<Google.Cloud.PubSub.V1.SubscriberClient\>.GetChannelPool()

### Validate()

    protected override void Validate()

Validates that the builder is in a consistent state for building. For example, it's invalid to call
[Build()](https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ClientBuilderBase-1.html#Google_Api_Gax_Grpc_ClientBuilderBase_1_Build) on an instance which has both JSON credentials and a credentials path specified.
**Overrides** Google.Api.Gax.Grpc.ClientBuilderBase\<Google.Cloud.PubSub.V1.SubscriberClient\>.Validate()

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.invalidoperationexception` | The builder is in an invalid state. |