public sealed class PublisherClientImpl : PublisherClient, IAsyncDisposable
Reference documentation and code samples for the Cloud Pub/Sub v1 API class PublisherClientImpl.
Implementation of PubSub publisher that is associated with a specific TopicName.
Implements
IAsyncDisposableNamespace
Google.Cloud.PubSub.V1Assembly
Google.Cloud.PubSub.V1.dll
Constructors
PublisherClientImpl(TopicName, IEnumerable<PublisherServiceApiClient>, 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 | |
---|---|
Name | Description |
topicName |
TopicName The TopicName to publish messages to. |
clients |
IEnumerablePublisherServiceApiClient The PublisherClients to use. |
settings |
PublisherClientSettings PublisherClient.Settings to use in this PublisherClientImpl. |
shutdown |
FuncTask Function to call on this PublisherClientImpl shutdown. |
Properties
TopicName
public override TopicName TopicName { get; }
The associated TopicName.
Property Value | |
---|---|
Type | Description |
TopicName |
Methods
DisposeAsync()
public override ValueTask DisposeAsync()
Disposes this PublisherClient asynchronously.
Returns | |
---|---|
Type | Description |
ValueTask |
This method asynchronously waits for the time interval as specified in the DisposeTimeout for the PublisherClient to send any pending messages. If the clean shutdown is not complete after this time, it is aborted; this may leave some locally queued messages unsent. The time interval can be customized by setting the DisposeTimeout.
PublishAsync(PubsubMessage)
public override Task<string> PublishAsync(PubsubMessage message)
Publish a message to the topic specified in TopicName.
Parameter | |
---|---|
Name | Description |
message |
PubsubMessage The PubsubMessage to publish. |
Returns | |
---|---|
Type | Description |
Taskstring |
A task which completes once the message has been published. The task Result contains the message ID. |
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 | |
---|---|
Name | Description |
orderingKey |
string The ordering key to re-enable. |
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 Task completes when all queued messages have been published.
The returned Task cancels if hardStopToken
is cancelled.
Parameter | |
---|---|
Name | Description |
hardStopToken |
CancellationToken Cancel this CancellationToken to abort publishing queued messages. |
Returns | |
---|---|
Type | Description |
Task |
A Task that completes when all queued messages have been published; or cancels if
|