From 4c83e18becbc7375e46fbfb4b14313c3e6cb5ed1 Mon Sep 17 00:00:00 2001 From: Peter Lamut Date: Mon, 15 Jun 2020 16:08:46 +0200 Subject: [PATCH 1/2] docs: explain how to nack a sync pull message --- docs/subscriber/index.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/subscriber/index.rst b/docs/subscriber/index.rst index d3d1cb541..5356df706 100644 --- a/docs/subscriber/index.rst +++ b/docs/subscriber/index.rst @@ -67,6 +67,17 @@ The method returns a :class:`~.pubsub_v1.types.PullResponse` instance that cointains a list of received :class:`~.pubsub_v1.types.ReceivedMessage` instances. +If you want to **nack** some of the received messages (see :ref:`explaining-ack` below), +you can use the :meth:`~.pubsub_v1.subscriber.client.Client.modify_ack_deadline` +method and set their acknowledge deadlines to zero. This will cause them to +expire instantly and the backend will try to re-deliver them. + +.. code-block:: python + + ack_ids = [] # TODO: populate with `ack_ids` of the messages to NACK + ack_deadline_seconds = 0 + subscriber.modify_ack_deadline(subscription_path, ack_ids, ack_deadline_seconds) + Pulling a Subscription Asynchronously ------------------------------------- @@ -159,6 +170,8 @@ receiving messages. future.cancel() +.. _explaining-ack: + Explaining Ack -------------- From 6639e8e63192571b6d1bc3f826b92c955b5bf426 Mon Sep 17 00:00:00 2001 From: Peter Lamut Date: Thu, 18 Jun 2020 19:39:20 +0200 Subject: [PATCH 2/2] Improve wording --- docs/subscriber/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/subscriber/index.rst b/docs/subscriber/index.rst index 5356df706..ed99566cd 100644 --- a/docs/subscriber/index.rst +++ b/docs/subscriber/index.rst @@ -64,13 +64,13 @@ To pull the messages synchronously, use the client's subscriber.acknowledge(subscription_path, ack_ids) The method returns a :class:`~.pubsub_v1.types.PullResponse` instance that -cointains a list of received :class:`~.pubsub_v1.types.ReceivedMessage` +contains a list of received :class:`~.pubsub_v1.types.ReceivedMessage` instances. If you want to **nack** some of the received messages (see :ref:`explaining-ack` below), you can use the :meth:`~.pubsub_v1.subscriber.client.Client.modify_ack_deadline` method and set their acknowledge deadlines to zero. This will cause them to -expire instantly and the backend will try to re-deliver them. +be dropped by this client and the backend will try to re-deliver them. .. code-block:: python