Class PublisherClientImpl (2.3.0)

public sealed class PublisherClientImpl : PublisherClient

Implementation of PubSub publisher that is associated with a specific TopicName.

Inheritance

System.Object > PublisherClient > PublisherClientImpl

Namespace

Google.Cloud.PubSub.V1

Assembly

Google.Cloud.PubSub.V1.dll

Constructors

PublisherClientImpl(TopicName, IEnumerable<PublisherServiceApiClient>, PublisherClient.Settings, Func<Task>)

public PublisherClientImpl(TopicName topicName, IEnumerable<PublisherServiceApiClient> clients, PublisherClient.Settings settings, Func<Task> shutdown)

Instantiate a PublisherClientImpl associated with the specified TopicName.

Parameters
NameDescription
topicNameTopicName

The TopicName to publish messages to.

clientsSystem.Collections.Generic.IEnumerable<PublisherServiceApiClient>

The PublisherClients to use.

settingsPublisherClient.Settings

PublisherClient.Settings to use in this PublisherClientImpl.

shutdownSystem.Func<System.Threading.Tasks.Task>

Function to call on this PublisherClientImpl shutdown.

Properties

TopicName

public override TopicName TopicName { get; }

The associated TopicName.

Property Value
TypeDescription
TopicName
Overrides

Methods

PublishAsync(PubsubMessage)

public override Task<string> PublishAsync(PubsubMessage message)

Publish a message to the topic specified in TopicName.

Parameter
NameDescription
messagePubsubMessage

The PubsubMessage to publish.

Returns
TypeDescription
System.Threading.Tasks.Task<System.String>

A task which completes once the message has been published. The task System.Threading.Tasks.Task`1.Result contains the message ID.

Overrides

ResumePublish(String)

public override void ResumePublish(string orderingKey)

Re-enable publishing the the given ordering key, after an error has caused the ordering key to be disabled.

Parameter
NameDescription
orderingKeySystem.String

The ordering key to re-enable.

Overrides

ShutdownAsync(CancellationToken)

public override Task ShutdownAsync(CancellationToken hardStopToken)

Shutdown this PublisherClient. Cancelling hardStopToken aborts the clean shutdown process, and may leave some locally queued messages unsent. The returned System.Threading.Tasks.Task completes when all queued messages have been published. The returned System.Threading.Tasks.Task cancels if hardStopToken is cancelled.

Parameter
NameDescription
hardStopTokenSystem.Threading.CancellationToken

Cancel this System.Threading.CancellationToken to abort publishing queued messages.

Returns
TypeDescription
System.Threading.Tasks.Task

A System.Threading.Tasks.Task that completes when all queued messages have been published; or cancels if hardStopToken is cancelled.

Overrides