# Cloud Pub/Sub v1 API - Class SubscriberClientImpl (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 SubscriberClientImpl : SubscriberClient, IAsyncDisposable

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

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

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) \> SubscriberClientImpl

## Implements

[IAsyncDisposable](https://learn.microsoft.com/dotnet/api/system.iasyncdisposable)

## Inherited Members

[SubscriberClient.DefaultFlowControlSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DefaultFlowControlSettings) [SubscriberClient.MinimumAckDeadline](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_MinimumAckDeadline) [SubscriberClient.MaximumAckDeadline](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_MaximumAckDeadline) [SubscriberClient.DefaultAckDeadline](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DefaultAckDeadline) [SubscriberClient.DefaultAckDeadlineForExactlyOnceDelivery](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DefaultAckDeadlineForExactlyOnceDelivery) [SubscriberClient.MinimumAckExtensionWindow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_MinimumAckExtensionWindow) [SubscriberClient.MinimumAckExtensionWindowForExactlyOnceDelivery](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_MinimumAckExtensionWindowForExactlyOnceDelivery) [SubscriberClient.DefaultAckExtensionWindow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DefaultAckExtensionWindow) [SubscriberClient.MinimumLeaseExtensionDelay](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_MinimumLeaseExtensionDelay) [SubscriberClient.DefaultMaxTotalAckExtension](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DefaultMaxTotalAckExtension) [SubscriberClient.DefaultDisposeTimeout](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DefaultDisposeTimeout) [SubscriberClient.Create(SubscriptionName)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_Create_Google_Cloud_PubSub_V1_SubscriptionName_) [SubscriberClient.CreateAsync(SubscriptionName)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_CreateAsync_Google_Cloud_PubSub_V1_SubscriptionName_) [SubscriberClient.Create(SubscriptionName, SubscriberClient.ClientCreationSettings, SubscriberClient.Settings)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_Create_Google_Cloud_PubSub_V1_SubscriptionName_Google_Cloud_PubSub_V1_SubscriberClient_ClientCreationSettings_Google_Cloud_PubSub_V1_SubscriberClient_Settings_) [SubscriberClient.CreateAsync(SubscriptionName, SubscriberClient.ClientCreationSettings, SubscriberClient.Settings)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_CreateAsync_Google_Cloud_PubSub_V1_SubscriptionName_Google_Cloud_PubSub_V1_SubscriberClient_ClientCreationSettings_Google_Cloud_PubSub_V1_SubscriberClient_Settings_) [SubscriberClient.StopAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_System_Threading_CancellationToken_) [SubscriberClient.StopAsync(TimeSpan)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_System_TimeSpan_) [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

### SubscriberClientImpl(SubscriptionName, IEnumerable\<SubscriberServiceApiClient\>, Settings, Func\<Task\>)

    public SubscriberClientImpl(SubscriptionName subscriptionName, IEnumerable<SubscriberServiceApiClient> clients, SubscriberClient.Settings settings, Func<Task> shutdown)

Instantiate a [SubscriberClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientImpl) associated with the specified [SubscriptionName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientImpl#Google_Cloud_PubSub_V1_SubscriberClientImpl_SubscriptionName).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `subscriptionName` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriptionName` The [SubscriptionName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientImpl#Google_Cloud_PubSub_V1_SubscriberClientImpl_SubscriptionName) to receive messages from. |
| `clients` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberServiceApiClient` The [SubscriberServiceApiClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberServiceApiClient)s to use in a [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient). For high performance, these should all use distinct [ChannelBase](https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ChannelBase.html)s. |
| `settings` | `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` [SubscriberClient.Settings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Settings) for creating a [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient). |
| `shutdown` | `https://learn.microsoft.com/dotnet/api/system.func-1https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` Function to call on this [SubscriberClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClientImpl) shutdown. |

## Properties

### SubscriptionName

    public override SubscriptionName SubscriptionName { get; }

The associated [SubscriptionName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_SubscriptionName).

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

**Overrides** [SubscriberClient.SubscriptionName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_SubscriptionName)

## Methods

### DisposeAsync()

    public override ValueTask DisposeAsync()

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask` |   |

**Overrides** [SubscriberClient.DisposeAsync()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_DisposeAsync) **Remarks** This method asynchronously waits for the time interval as specified in the [DisposeTimeout](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Settings#Google_Cloud_PubSub_V1_SubscriberClient_Settings_DisposeTimeout)
for the [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) to acknowledge the handled messages. If the clean shutdown is not
complete after this time, it is aborted; this may leave some handled messages un-acknowledged.
The time interval can be customized by setting the [DisposeTimeout](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Settings#Google_Cloud_PubSub_V1_SubscriberClient_Settings_DisposeTimeout).

### StartAsync(SubscriptionHandler)

    public override Task StartAsync(SubscriptionHandler handler)

Starts receiving messages. The returned [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) completes when either [StopAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_System_Threading_CancellationToken_) is called
or if an unrecoverable fault occurs. See [StopAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_System_Threading_CancellationToken_) for more details.
This method cannot be called more than once per [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) instance.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `handler` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriptionHandler` The handler that is passed all received messages and acknowledgement results. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that completes when the subscriber is stopped, or if an unrecoverable error occurs. |

**Overrides** [SubscriberClient.StartAsync(SubscriptionHandler)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StartAsync_Google_Cloud_PubSub_V1_SubscriptionHandler_)

### StartAsync(Func\<PubsubMessage, CancellationToken, Task\<Reply\>\>)

    public override Task StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>> handlerAsync)

Starts receiving messages. The returned [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) completes when either [StopAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_System_Threading_CancellationToken_) is called
or if an unrecoverable fault occurs. See [StopAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_System_Threading_CancellationToken_) for more details.
This method cannot be called more than once per [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient) instance.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `handlerAsync` | `https://learn.microsoft.com/dotnet/api/system.func-3https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.PubsubMessagehttps://learn.microsoft.com/dotnet/api/system.threading.cancellationtokenhttps://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.SubscriberClienthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Reply` The handler function that is passed all received messages. This function may be called on multiple threads concurrently. Return [Ack](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Reply#Google_Cloud_PubSub_V1_SubscriberClient_Reply_Ack) from this function to acknowledge this message (implying it won't be received again); or return [Nack](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Reply#Google_Cloud_PubSub_V1_SubscriberClient_Reply_Nack) to Not acknowledge this message (implying it will be received again). If this function throws any Exception, then it behaves as if it returned [Nack](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.Reply#Google_Cloud_PubSub_V1_SubscriberClient_Reply_Nack). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that completes when the subscriber is stopped, or if an unrecoverable error occurs. |

**Overrides** [SubscriberClient.StartAsync(Func\<PubsubMessage, CancellationToken, Task\<SubscriberClient.Reply\>\>)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StartAsync_System_Func_Google_Cloud_PubSub_V1_PubsubMessage_System_Threading_CancellationToken_System_Threading_Tasks_Task_Google_Cloud_PubSub_V1_SubscriberClient_Reply___)

### StopAsync(ShutdownOptions, CancellationToken)

    public override Task StopAsync(SubscriberClient.ShutdownOptions shutdownOptions, CancellationToken cancellationToken = default)

Stops this [SubscriberClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient).
The returned [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) completes when the shutdown is finished according to the
`shutdownOptions` or when the `cancellationToken` is cancelled.
The returned [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) faults if an unrecoverable error occurs in the underlying service.
The returned [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) cancels if `cancellationToken` is cancelled.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `shutdownOptions` | `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.ShutdownOptions` The [SubscriberClient.ShutdownOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient.ShutdownOptions) to use for shutdown. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancel this [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to immediately abort handlers and acknowledgement. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) that completes when the subscriber is stopped, or if an unrecoverable error occurs. |

**Overrides** [SubscriberClient.StopAsync(SubscriberClient.ShutdownOptions, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.SubscriberClient#Google_Cloud_PubSub_V1_SubscriberClient_StopAsync_Google_Cloud_PubSub_V1_SubscriberClient_ShutdownOptions_System_Threading_CancellationToken_)