Filtering notification

369 views
Skip to first unread message

Anchal Gupta

unread,
Mar 11, 2021, 5:32:22 AM3/11/21
to Google Cloud Pub/Sub Discussions
Hi Group,

Use case - Our GCS bucket has folders and then objects inside them. When any object in our GCS bucket changes in any way, then it is generating notification and sending it to Pub/Sub topic. And then from pub/sub  it's getting pushed to our backend app.

Requirement - We only want one notification when a folder is created, instead of getting notified for all the object created inside the folder. Our backend service only wants to get one notification when a folder with multiple files is added.
For example, if a folder is created with 120 files inside it, we just want to receive 1 notification with folder details. We don't need the object/files details.

Current solution - Currently we are receiving all notification and processing each one of them.

Is there a better way to handle this scenario to avoid processing these many request?


Thank you 

plaj

unread,
Mar 11, 2021, 7:00:45 AM3/11/21
to Google Cloud Pub/Sub Discussions
Hi there,

While you can set multiple notification configurations to a bucket, I haven't been able to set an explicit option to filter notifications to only created folders. However, I believe you could try to check within the Payload [1] provided in the Events for signs that the current event is indeed a folder (i.e name of the object ends with a slash "/"), and filter only those items. In that sense, I have found this old post in Stack Overflow that could be helpful, as it filters notifications to only objects ending with "/" [2].

I hope this information addresses your concerns.

Anchal Gupta

unread,
Mar 12, 2021, 11:24:54 AM3/12/21
to Google Cloud Pub/Sub Discussions
Thank you for the helping with it.
Reply all
Reply to author
Forward
0 new messages