public abstract class PublisherClientA PubSub publisher that is associated with a specific TopicName.
Derived Types
Namespace
Google.Cloud.PubSub.V1Assembly
Google.Cloud.PubSub.V1.dll
Properties
ApiMaxBatchingSettings
public static BatchingSettings ApiMaxBatchingSettings { get; }The absolute maximum BatchingSettings supported by the service. Maximum values are: ElementCountThreshold = 1,000; ByteCountThreshold = 10,000,000;
| Property Value | |
|---|---|
| Type | Description |
BatchingSettings |
|
DefaultBatchingSettings
public static BatchingSettings DefaultBatchingSettings { get; }Default BatchingSettings for PublisherClient. Default values are: ElementCountThreshold = 100; ByteCountThreshold = 1,000,000; DelayThreshold = 10 milliseconds;
| Property Value | |
|---|---|
| Type | Description |
BatchingSettings |
|
TopicName
public virtual TopicName TopicName { get; }The associated TopicName.
| Property Value | |
|---|---|
| Type | Description |
TopicName |
|
Methods
Create(TopicName, PublisherClient.ClientCreationSettings, PublisherClient.Settings)
public static PublisherClient Create(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.Retry.
By default this method generates a gRPC channel per CPU core; if using a high-core-count machine and using many
clients concurrently then this may need reducing; use the setting ClientCount.
| Parameters | |
|---|---|
| Name | Description |
topicName |
TopicNameThe TopicName to publish messages to. |
clientCreationSettings |
PublisherClient.ClientCreationSettingsOptional. PublisherClient.ClientCreationSettings specifying how to create PublisherServiceApiClients. |
settings |
PublisherClient.SettingsOptional. PublisherClient.Settings for creating a PublisherClient. |
| Returns | |
|---|---|
| Type | Description |
PublisherClient |
A PublisherClient instance associated with the specified TopicName. |
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.Retry.
By default this method generates a gRPC channel per CPU core; if using a high-core-count machine and using many
clients concurrently then this may need reducing; use the setting ClientCount.
| Parameters | |
|---|---|
| Name | Description |
topicName |
TopicNameThe TopicName to publish messages to. |
clientCreationSettings |
PublisherClient.ClientCreationSettingsOptional. PublisherClient.ClientCreationSettings specifying how to create PublisherServiceApiClients. |
settings |
PublisherClient.SettingsOptional. PublisherClient.Settings for creating a PublisherClient. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
message |
PubsubMessageThe PubsubMessage to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task Result contains the message ID. |
PublishAsync(ByteString)
public virtual Task<string> PublishAsync(ByteString message)Publish a message to the topic specified in TopicName.
| Parameter | |
|---|---|
| Name | Description |
message |
ByteStringThe ByteString to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task Result contains the message ID. |
PublishAsync(IMessage)
public virtual Task<string> PublishAsync(IMessage message)Publish a message to the topic specified in TopicName.
| Parameter | |
|---|---|
| Name | Description |
message |
IMessageThe message to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task Result contains the message ID. |
PublishAsync(Byte[])
public virtual Task<string> PublishAsync(byte[] message)Publish a message to the topic specified in TopicName.
| Parameter | |
|---|---|
| Name | Description |
message |
Byte[]The message to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task 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 | |
|---|---|
| Name | Description |
orderingKey |
StringThe ordering key to use for this message. |
message |
ByteStringThe ByteString to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task 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 | |
|---|---|
| Name | Description |
orderingKey |
StringThe ordering key to use for this message. |
message |
IMessageThe message to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task 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 | |
|---|---|
| Name | Description |
orderingKey |
StringThe ordering key to use for this message. |
message |
Byte[]The message to publish. |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task 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 | |
|---|---|
| Name | Description |
orderingKey |
StringThe ordering key to use for this message. |
message |
StringThe string to publish. |
encoding |
EncodingThe encoding for string to byte conversion.
If |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task 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 | |
|---|---|
| Name | Description |
message |
StringThe string to publish. |
encoding |
EncodingThe encoding for string to byte conversion.
If |
| Returns | |
|---|---|
| Type | Description |
Task<String> |
A task which completes once the message has been published. The task 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 | |
|---|---|
| Name | Description |
orderingKey |
StringThe 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 Task completes when all queued messages have been published.
The returned Task cancels if hardStopToken is cancelled.
| Parameter | |
|---|---|
| Name | Description |
hardStopToken |
CancellationTokenCancel 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
|
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 Task completes when all queued messages have been published.
The returned Task cancels if the timeout expires before all messages are published.
| Parameter | |
|---|---|
| Name | Description |
timeout |
TimeSpanAfter this period, abort publishing queued messages. |
| Returns | |
|---|---|
| Type | Description |
Task |
A Task that completes when all queued messages have been published; or cancels if
|