Pub/Sub resend count

1,538 views
Skip to first unread message

Irfan Ismail

unread,
Mar 7, 2017, 11:29:00 AM3/7/17
to Google Cloud Pub/Sub Discussions
Hi all,

Is it possible to know how many times message have been resent by Pub/Sub, for example cause by acknowledgement deadline expires? Some thing like message.getResendCount()

Thanks.

Kir Titievsky

unread,
Mar 7, 2017, 11:32:21 AM3/7/17
to Irfan Ismail, Google Cloud Pub/Sub Discussions
Hi, Ifran,

You cannot get this information for an individual message from Pub/Sub.  You might be able to solve the problem you are after by looking at the age of the message as well as to diagnose problems with multiple messages by looking at service metrics in Stackdriver.

Could you tell us more about what resend count might help you do?

k

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/422a7b1e-d1b8-4107-8ab0-1f3732adcce2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

Irfan Ismail

unread,
Mar 7, 2017, 12:17:15 PM3/7/17
to Google Cloud Pub/Sub Discussions, is.ir...@gmail.com
Hi Kir Titievsky,

I use PubSub as a queue of task for calling 3rd party API. Messages in queue are consumed by a cluster of subscribers (using same "Pub/Sub subscription"). Depend on message being processed, the subscriber call certain 3rd party API.
If the call failed with some error code or RTO, I want Pub/Sub to resend the message to retry the process until some "max retry value".

Kir Titievsky

unread,
Mar 7, 2017, 12:28:54 PM3/7/17
to Irfan Ismail, Google Cloud Pub/Sub Discussions
Irfan, There's another way to handle this: if the 3rd party API call fails, you publish another message with the same content as the original but a message attribute that contains a count of failed calls.  You then acknowledge the original message.

This solution has some limitations: 
- You code must not crash before handling the 3rd party API error;
- You will sometimes get the same message more than once.

But overall this should help isolate most of the "bad messages" without losing any.

Let me know if this might work for you.

k

On Tue, Mar 7, 2017 at 12:13 PM, Irfan Ismail <is.ir...@gmail.com> wrote:
Hi Kir Titievsky,

I use PubSub as a queue of task for calling 3rd party API. Messages in queue are consumed by a cluster of subscribers (using same "Pub/Sub subscription"). Depend on message being processed, the subscriber call certain 3rd party API.
If the call failed with some error code or RTO, I want Pub/Sub to resend the message to retry the process until some "max retry value".

On Tuesday, March 7, 2017 at 11:32:21 PM UTC+7, Kir Titievsky wrote:
Hi, Ifran,

You cannot get this information for an individual message from Pub/Sub.  You might be able to solve the problem you are after by looking at the age of the message as well as to diagnose problems with multiple messages by looking at service metrics in Stackdriver.

Could you tell us more about what resend count might help you do?

k
On Tue, Mar 7, 2017 at 11:21 AM, Irfan Ismail <is.ir...@gmail.com> wrote:
Hi all,

Is it possible to know how many times message have been resent by Pub/Sub, for example cause by acknowledgement deadline expires? Some thing like message.getResendCount()

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsubscrib...@googlegroups.com.



--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Irfan Ismail

unread,
Mar 8, 2017, 10:31:00 AM3/8/17
to Google Cloud Pub/Sub Discussions, is.ir...@gmail.com
Hi k,

For my use case, I think duplicate message will cause issue because some of API call is non idempotent.
Is there any suggestion to tackle this issue?

Regards,
Irfan


On Wednesday, March 8, 2017 at 12:28:54 AM UTC+7, Kir Titievsky wrote:
Irfan, There's another way to handle this: if the 3rd party API call fails, you publish another message with the same content as the original but a message attribute that contains a count of failed calls.  You then acknowledge the original message.

This solution has some limitations: 
- You code must not crash before handling the 3rd party API error;
- You will sometimes get the same message more than once.

But overall this should help isolate most of the "bad messages" without losing any.

Let me know if this might work for you.

k
On Tue, Mar 7, 2017 at 12:13 PM, Irfan Ismail <is.ir...@gmail.com> wrote:
Hi Kir Titievsky,

I use PubSub as a queue of task for calling 3rd party API. Messages in queue are consumed by a cluster of subscribers (using same "Pub/Sub subscription"). Depend on message being processed, the subscriber call certain 3rd party API.
If the call failed with some error code or RTO, I want Pub/Sub to resend the message to retry the process until some "max retry value".

On Tuesday, March 7, 2017 at 11:32:21 PM UTC+7, Kir Titievsky wrote:
Hi, Ifran,

You cannot get this information for an individual message from Pub/Sub.  You might be able to solve the problem you are after by looking at the age of the message as well as to diagnose problems with multiple messages by looking at service metrics in Stackdriver.

Could you tell us more about what resend count might help you do?

k
On Tue, Mar 7, 2017 at 11:21 AM, Irfan Ismail <is.ir...@gmail.com> wrote:
Hi all,

Is it possible to know how many times message have been resent by Pub/Sub, for example cause by acknowledgement deadline expires? Some thing like message.getResendCount()

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/422a7b1e-d1b8-4107-8ab0-1f3732adcce2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/165ed343-1af3-4402-9e10-072d452b1bed%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thomas Kneeland

unread,
Mar 8, 2017, 4:31:14 PM3/8/17
to Irfan Ismail, Google Cloud Pub/Sub Discussions
Hi Irfan,

Cloud Pub/Sub guarantees at-least-once message delivery, so in general, your subscribers must be capable of handling duplicate messages. Note that this issue is not unique to Cloud Pub/Sub: How do you choose to handle the situation if your worker crashes before, during, or after the non-idempotent API call?

Best,
Thomas

To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsubscrib...@googlegroups.com.



--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsubscrib...@googlegroups.com.



--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsubscrib...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/8a8c5175-b62d-4656-9774-5d284059ce49%40googlegroups.com.

Irfan Ismail

unread,
Apr 21, 2017, 9:17:54 AM4/21/17
to Google Cloud Pub/Sub Discussions, is.ir...@gmail.com
I found method modifyAckDeadline on Pub/Sub ReceivedMessage to reset deadline, I think I could use this to prevent duplicate message.
Reply all
Reply to author
Forward
0 new messages