Class PublisherClient (1.12.0)
Stay organized with collections
Save and categorize content based on your preferences.
PublisherClient(
*,
per_partition_batching_settings: typing.Optional[
google.cloud.pubsub_v1.types.BatchSettings
] = None,
credentials: typing.Optional[google.auth.credentials.Credentials] = None,
transport: str = "grpc_asyncio",
client_options: typing.Optional[
google.api_core.client_options.ClientOptions
] = None,
enable_idempotence: bool = False
)
A PublisherClient publishes messages similar to Google Pub/Sub.
Any publish failures are unlikely to succeed if retried.
Must be used in a with
block or have enter() called before use.
Methods
PublisherClient
PublisherClient(
*,
per_partition_batching_settings: typing.Optional[
google.cloud.pubsub_v1.types.BatchSettings
] = None,
credentials: typing.Optional[google.auth.credentials.Credentials] = None,
transport: str = "grpc_asyncio",
client_options: typing.Optional[
google.api_core.client_options.ClientOptions
] = None,
enable_idempotence: bool = False
)
Create a new PublisherClient.
__enter__
Return self
upon entering the runtime context.
__exit__
__exit__(exc_type, exc_value, traceback)
Raise any exception triggered within the runtime context.
publish
publish(
topic: typing.Union[google.cloud.pubsublite.types.paths.TopicPath, str],
data: bytes,
ordering_key: str = "",
**attrs: typing.Mapping[str, str]
) -> concurrent.futures._base.Future[str]
Exceptions |
Type |
Description |
GoogleApiCallError |
On a permanent failure. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class PublisherClient (1.12.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.12.0 (latest)](/python/docs/reference/pubsublite/latest/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.11.1](/python/docs/reference/pubsublite/1.11.1/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.10.0](/python/docs/reference/pubsublite/1.10.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.9.0](/python/docs/reference/pubsublite/1.9.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.8.3](/python/docs/reference/pubsublite/1.8.3/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.7.0](/python/docs/reference/pubsublite/1.7.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.6.0](/python/docs/reference/pubsublite/1.6.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.5.0](/python/docs/reference/pubsublite/1.5.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.4.3](/python/docs/reference/pubsublite/1.4.3/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.3.0](/python/docs/reference/pubsublite/1.3.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.2.0](/python/docs/reference/pubsublite/1.2.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.1.4](/python/docs/reference/pubsublite/1.1.4/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [1.0.2](/python/docs/reference/pubsublite/1.0.2/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [0.6.1](/python/docs/reference/pubsublite/0.6.1/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [0.5.0](/python/docs/reference/pubsublite/0.5.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [0.4.1](/python/docs/reference/pubsublite/0.4.1/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [0.3.0](/python/docs/reference/pubsublite/0.3.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [0.2.0](/python/docs/reference/pubsublite/0.2.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient)\n- [0.1.0](/python/docs/reference/pubsublite/0.1.0/google.cloud.pubsublite.cloudpubsub.publisher_client.PublisherClient) \n\n PublisherClient(\n *,\n per_partition_batching_settings: typing.Optional[\n google.cloud.pubsub_v1.types.BatchSettings\n ] = None,\n credentials: typing.Optional[google.auth.credentials.Credentials] = None,\n transport: str = \"grpc_asyncio\",\n client_options: typing.Optional[\n google.api_core.client_options.ClientOptions\n ] = None,\n enable_idempotence: bool = False\n )\n\nA PublisherClient publishes messages similar to Google Pub/Sub.\nAny publish failures are unlikely to succeed if retried.\n\nMust be used in a `with` block or have **enter**() called before use.\n\nMethods\n-------\n\n### PublisherClient\n\n PublisherClient(\n *,\n per_partition_batching_settings: typing.Optional[\n google.cloud.pubsub_v1.types.BatchSettings\n ] = None,\n credentials: typing.Optional[google.auth.credentials.Credentials] = None,\n transport: str = \"grpc_asyncio\",\n client_options: typing.Optional[\n google.api_core.client_options.ClientOptions\n ] = None,\n enable_idempotence: bool = False\n )\n\nCreate a new PublisherClient.\n\n### __enter__\n\n __enter__()\n\nReturn `self` upon entering the runtime context.\n\n### __exit__\n\n __exit__(exc_type, exc_value, traceback)\n\nRaise any exception triggered within the runtime context.\n\n### publish\n\n publish(\n topic: typing.Union[google.cloud.pubsublite.types.paths.TopicPath, str],\n data: bytes,\n ordering_key: str = \"\",\n **attrs: typing.Mapping[str, str]\n ) -\u003e concurrent.futures._base.Future[str]\n\nPublish a message."]]