Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

google cloud pub/sub error to get push notification through users.watch() of gmail api

I used google pub/sub to get push notification through users.watch() of gmail api. However, google pub/sub keeps calling webhooks for certain user's specific history id for no reason.

gwak_0-1682700424866.png

 

0 1 982
1 REPLY 1

Good day @gwak ,

Welcome to Google Cloud Community! 

Pub/Sub were designed to make the messages delivered at least once, which means that the messages can also be delivered multiple times or more than once, You can check this link to learn more: https://cloud.google.com/pubsub/docs/subscriber#at-least-once-delivery

1. Check if you have acknowledged the message, This might be a redelivery, these issue indicates that the user might have failed to acknowledge the message within the acknowledgement deadline or the user sends a negative acknowledgement so pub/sub is trying to redeliver the message. You can try extending the deadline and check if the issue will be resolved, You can learn more here: https://cloud.google.com/pubsub/docs/exactly-once-delivery#redelivery_versus_duplicate
You can also implement 'Exactly once deliver' which will stop the redelivery of the messages once it is acknowledged. You can check this documentation to learn more: https://cloud.google.com/pubsub/docs/exactly-once-delivery#console

2. You can also try implementing using Dataflow, it can be used de-duplicate the messages. You can learn more using this link: https://cloud.google.com/blog/products/data-analytics/handling-duplicate-data-in-streaming-pipeline-...

3. Try also checking if the problem might be in the code in your API request.
 
Hope it helps!

Top Solution Authors