Skip to content

Instantly share code, notes, and snippets.

@babo
Last active September 14, 2020 09:51
Show Gist options
  • Select an option

  • Save babo/eca8a02a26f696a6d9960045c7691f13 to your computer and use it in GitHub Desktop.

Select an option

Save babo/eca8a02a26f696a6d9960045c7691f13 to your computer and use it in GitHub Desktop.
Delete a specific message
import json
from google.cloud import pubsub
# Instantiates a client
pubsub_client = pubsub.Client()
sbscr = pubsub_client.subscription('demoapi_subscription_createTenant')
i = 0
while True:
for x in sbscr.pull(return_immediately=True):
data = json.loads(x[1].data)
if data:
if data['processId'] == '081f211b-f77d-4a80-8f77-a650c85763a5':
sbscr.acknowledge([x[0]])
i += 1
if i % 100 == 0:
print(i)
else:
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment