Class PublisherClient (2.3.0)

public abstract class PublisherClient

A PubSub publisher that is associated with a specific TopicName.

Inheritance

System.Object > PublisherClient

Namespace

Google.Cloud.PubSub.V1

Assembly

Google.Cloud.PubSub.V1.dll

Properties

ApiMaxBatchingSettings

public static BatchingSettings ApiMaxBatchingSettings { get; }

The absolute maximum Google.Api.Gax.BatchingSettings supported by the service. Maximum values are: Google.Api.Gax.BatchingSettings.ElementCountThreshold = 1,000; Google.Api.Gax.BatchingSettings.ByteCountThreshold = 10,000,000;

Property Value
TypeDescription
Google.Api.Gax.BatchingSettings

DefaultBatchingSettings

public static BatchingSettings DefaultBatchingSettings { get; }

Default Google.Api.Gax.BatchingSettings for PublisherClient. Default values are: Google.Api.Gax.BatchingSettings.ElementCountThreshold = 100; Google.Api.Gax.BatchingSettings.ByteCountThreshold = 1,000,000; Google.Api.Gax.BatchingSettings.DelayThreshold = 10 milliseconds;

Property Value
TypeDescription
Google.Api.Gax.BatchingSettings

TopicName

public virtual TopicName TopicName { get; }

The associated TopicName.

Property Value
TypeDescription
TopicName

Methods

CreateAsync(TopicName, PublisherClient.ClientCreationSettings, PublisherClient.Settings)

public static Task<PublisherClient> CreateAsync(TopicName topicName, PublisherClient.ClientCreationSettings clientCreationSettings = null, PublisherClient.Settings settings = null)

Create a PublisherClient instance associated with the specified TopicName. The default settings and clientCreationSettings are suitable for machines with high network bandwidth (e.g. Google Compute Engine instances). If running with more limited network bandwidth, some settings may need changing; especially PublisherServiceApiSettings.PublishSettings.Google.Api.Gax.Grpc.CallSettings.Retry.

Parameters
NameDescription
topicNameTopicName

The TopicName to publish messages to.

clientCreationSettingsPublisherClient.ClientCreationSettings

Optional. PublisherClient.ClientCreationSettings specifying how to create PublisherServiceApiClients.

settingsPublisherClient.Settings

Optional. PublisherClient.Settings for creating a PublisherClient.

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

A PublisherClient instance associated with the specified TopicName.

PublishAsync(PubsubMessage)

public virtual 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.

PublishAsync(ByteString)

public virtual Task<string> PublishAsync(ByteString message)

Publish a message to the topic specified in TopicName.

Parameter
NameDescription
messageGoogle.Protobuf.ByteString

The Google.Protobuf.ByteString 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.

PublishAsync(IMessage)

public virtual Task<string> PublishAsync(IMessage message)

Publish a message to the topic specified in TopicName.

Parameter
NameDescription
messageGoogle.Protobuf.IMessage

The message 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.

PublishAsync(Byte[])

public virtual Task<string> PublishAsync(byte[] message)

Publish a message to the topic specified in TopicName.

Parameter
NameDescription
messageSystem.Byte[]

The message 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.

PublishAsync(String, ByteString)

public virtual Task<string> PublishAsync(string orderingKey, ByteString message)

Publish a message to the topic specified in TopicName.

Parameters
NameDescription
orderingKeySystem.String

The ordering key to use for this message.

messageGoogle.Protobuf.ByteString

The Google.Protobuf.ByteString 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.

PublishAsync(String, IMessage)

public virtual Task<string> PublishAsync(string orderingKey, IMessage message)

Publish a message to the topic specified in TopicName.

Parameters
NameDescription
orderingKeySystem.String

The ordering key to use for this message.

messageGoogle.Protobuf.IMessage

The message 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.

PublishAsync(String, Byte[])

public virtual Task<string> PublishAsync(string orderingKey, byte[] message)

Publish a message to the topic specified in TopicName.

Parameters
NameDescription
orderingKeySystem.String

The ordering key to use for this message.

messageSystem.Byte[]

The message 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.

PublishAsync(String, String, Encoding)

public virtual Task<string> PublishAsync(string orderingKey, string message, Encoding encoding = null)

Publish a message to the topic specified in TopicName.

Parameters
NameDescription
orderingKeySystem.String

The ordering key to use for this message.

messageSystem.String

The string to publish.

encodingSystem.Text.Encoding

The encoding for string to byte conversion. If null, defaults to System.Text.Encoding.UTF8.

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.

PublishAsync(String, Encoding)

public virtual Task<string> PublishAsync(string message, Encoding encoding = null)

Publish a message to the topic specified in TopicName.

Parameters
NameDescription
messageSystem.String

The string to publish.

encodingSystem.Text.Encoding

The encoding for string to byte conversion. If null, defaults to System.Text.Encoding.UTF8.

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.

ResumePublish(String)

public virtual 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.

ShutdownAsync(CancellationToken)

public virtual 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.

ShutdownAsync(TimeSpan)

public virtual Task ShutdownAsync(TimeSpan timeout)

Shutdown this PublisherClient. If timeout expires, the clean shutdown process will abort; leaving 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 the timeout expires before all messages are published.

Parameter
NameDescription
timeoutSystem.TimeSpan

After this period, 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 timeout expires.