[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-17。"],[],[],null,["# Subscription overview\n\n| **Key Point:** Learn about the basic workflow and properties for a Pub/Sub subscription.\n\nTo receive messages published to a topic, you must create a subscription to that\ntopic. Only messages published to the topic after the subscription is created\nare available to subscriber clients. The subscriber client receives and\nprocesses the messages published to the topic. A topic can have multiple\nsubscriptions, but a given subscription belongs to a single topic.\n\nThe topic retention feature lets a subscription attached to a topic to seek back\nin time and replay previously published messages. You can learn more about the\nfeature in the topic [Replaying and purging messages](/pubsub/docs/replay-overview).\n\nSubscription workflow\n---------------------\n\n1. After a message is sent to a subscriber, the subscriber must acknowledge the\n message.\n\n2. If a message is sent out for delivery and a subscriber is yet to acknowledge\n it, the message is called outstanding.\n\n3. Pub/Sub repeatedly attempts to deliver any message that is\n not yet acknowledged. However, Pub/Sub tries not to deliver\n an outstanding message to any other subscriber on the same subscription.\n\n4. The subscriber has a configurable, limited amount of time, known as the\n `ackDeadline`, to acknowledge the outstanding message. After the deadline\n passes, the message is no longer considered outstanding, and\n Pub/Sub attempts to redeliver the message.\n\nTypes of subscriptions\n----------------------\n\nWhen you create a subscription, you must specify the type of message delivery.\nPub/Sub offers the following types of subscriptions:\n\n- **Pull subscriptions** use a subscriber client to request messages from\n the Pub/Sub server.\n\n- **Push subscriptions** use the Pub/Sub server to initiate\n requests to your subscriber application to deliver messages.\n\n- **Export subscriptions** help you export your messages directly to a\n Google Cloud resource. These subscriptions include the following:\n\n - **BigQuery subscriptions** export data to a\n BigQuery table.\n\n - **Cloud Storage subscriptions** export data to a\n Cloud Storage bucket.\n\nTo choose the correct subscription for your business requirements, see\n[Choose a subscription type](/pubsub/docs/subscriber). You can [update the\ntype of message delivery](/pubsub/docs/manage-subscriptions) for a subscription\nat any time after its creation.\n\nDefault subscription properties\n-------------------------------\n\nBy default, Pub/Sub offers at-least-once delivery with no\nordering guarantees on all subscription types. Alternatively, if messages have\nthe same ordering key and are in the same region, you can enable [message\nordering](/pubsub/docs/ordering). After you set the message ordering property,\nthe Pub/Sub service delivers messages with the same ordering key\nand in the order that the Pub/Sub service receives the messages.\n\nPub/Sub also supports [exactly-once delivery](/pubsub/docs/exactly-once-delivery).\n\nIn general, Pub/Sub delivers each message once and in the order\nin which it was published. However, messages may sometimes be delivered out of\norder or more than once. Pub/Sub might redeliver a message even\nafter an acknowledgment request for the message returns successfully. This\nredelivery can be caused by issues such as server-side restarts or client-side\nissues. Thus, although rare, any message can be redelivered at any time.\n\nAccommodating more-than-once delivery requires your subscriber to be\n[idempotent](https://en.wikipedia.org/wiki/Idempotence#Computer_science_meaning)\nwhen processing messages.\n\nSubscription expiry\n-------------------\n\nBy default, subscriptions expire after 31 days of subscriber inactivity or if\nthere are no updates made to the subscription. Examples of subscriber activities\ninclude open connections, active pulls, or successful pushes. If\nPub/Sub detects subscriber activity or an update to the\nsubscription properties, the subscription deletion clock restarts. Using\n[subscription expiration](/pubsub/docs/subscription-properties#expiration_period) policies,\nyou can configure the inactivity duration or make the subscription persistent\nregardless of activity. You can also\n[delete](/pubsub/docs/delete-subscriptions) a subscription manually.\n\nAlthough you can create a new subscription with the same name as a deleted one,\nthe new subscription has no relationship to the old one. Even if the deleted\nsubscription had many unacknowledged messages, a new subscription created with\nthe same name would have no backlog (no messages waiting for delivery) at the\ntime it's created.\n\nWhat's next\n-----------\n\n- Choose the [correct type of subscription](/pubsub/docs/subscriber) for your business requirements.\n\n- Understand the workflow for each type of subscription:\n\n - [Pull](/pubsub/docs/pull)\n\n - [Push](/pubsub/docs/push)\n\n - [BigQuery](/pubsub/docs/bigquery)\n\n - [Cloud Storage](/pubsub/docs/cloudstorage)\n\n- Read about the different [subscription properties](/pubsub/docs/subscription-properties)."]]