An AsyncPublisherClient publishes messages similar to Google Pub/Sub, but must be used in an
async context. Any publish failures are unlikely to succeed if retried.
Must be used in an async with block or have aenter() awaited before use.
[[["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 AsyncPublisherClient (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.AsyncPublisherClient)\n- [1.11.1](/python/docs/reference/pubsublite/1.11.1/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.10.0](/python/docs/reference/pubsublite/1.10.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.9.0](/python/docs/reference/pubsublite/1.9.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.8.3](/python/docs/reference/pubsublite/1.8.3/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.7.0](/python/docs/reference/pubsublite/1.7.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.6.0](/python/docs/reference/pubsublite/1.6.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.5.0](/python/docs/reference/pubsublite/1.5.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.4.3](/python/docs/reference/pubsublite/1.4.3/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.3.0](/python/docs/reference/pubsublite/1.3.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.2.0](/python/docs/reference/pubsublite/1.2.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.1.4](/python/docs/reference/pubsublite/1.1.4/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [1.0.2](/python/docs/reference/pubsublite/1.0.2/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [0.6.1](/python/docs/reference/pubsublite/0.6.1/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [0.5.0](/python/docs/reference/pubsublite/0.5.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [0.4.1](/python/docs/reference/pubsublite/0.4.1/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [0.3.0](/python/docs/reference/pubsublite/0.3.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [0.2.0](/python/docs/reference/pubsublite/0.2.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient)\n- [0.1.0](/python/docs/reference/pubsublite/0.1.0/google.cloud.pubsublite.cloudpubsub.publisher_client.AsyncPublisherClient) \n\n AsyncPublisherClient(\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\nAn AsyncPublisherClient publishes messages similar to Google Pub/Sub, but must be used in an\nasync context. Any publish failures are unlikely to succeed if retried.\n\nMust be used in an `async with` block or have **aenter**() awaited before use.\n\nMethods\n-------\n\n### AsyncPublisherClient\n\n AsyncPublisherClient(\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 AsyncPublisherClient.\n\n### __aenter__\n\n __aenter__()\n\nReturn `self` upon entering the runtime context.\n\n### __aexit__\n\n __aexit__(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 str\n\nPublish a message."]]