This page contains code samples for Pub/Sub. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Detach subscription from topic
When a topic admin client detaches a subscription, the subscription is no longer allowed to read any data from the topic, and all stored messages on this subscription -- unacknowledged and acknowledged -- are dropped.
Publish messages with compression rate
Create a publisher with compression enabled and compression bytes threshold set, and publish some messages.
Resume publishing with ordering keys
When publishing with an ordering key fails, queued-up messages of the same ordering key in the publisher fail, as well as future publish requests of this ordering key. This sample shows how to resume publishing with ordering keys enabled when such failures occur.