PubSub messages not showing event type for Cloud storage notification

Viewed 210

As mentioned in this PubSub Notifications Attributes Documentation, I should be able to retrieve the Attributes such as eventType for all notifications sent by Cloud Storage to Pub/Sub topic.

However, in my case, I am not seeing any of the payload attributes when an object is added/removed from a cloud storage bucket that has been configured to send notifications.

Below is the message I am getting when an object is added to a cloud storage bucket:

{
  "kind": "storage#object",
  "id": "coral-ethos-xxxx.appspot.com/part-00000-of-00001.avro/1642783080470217",
  "selfLink": "https://www.googleapis.com/storage/v1/b/coral-ethos-xxxxx.appspot.com/o/part-00000-of-00001.avro",
  "name": "part-00000-of-00001.avro",
  "bucket": "coral-ethos-xxxxx.appspot.com",
  "generation": "1642783080470217",
  "metageneration": "1",
  "contentType": "application/octet-stream",
  "timeCreated": "2022-01-21T16:38:00.624Z",
  "updated": "2022-01-21T16:38:00.624Z",
  "storageClass": "STANDARD",
  "timeStorageClassUpdated": "2022-01-21T16:38:00.624Z",
  "size": "202521",
  "md5Hash": "w0QzRMUCOHj42vpME2P/Ww==",
  "mediaLink": "https://www.googleapis.com/download/storage/v1/b/coral-ethos-xxxxxx.appspot.com/o/part-00000-of-00001.avro?generation=1642783080470217&alt=media",
  "contentLanguage": "en",
  "crc32c": "XdhSwg==",
  "etag": "CMmt0e+jw/UCEAE="
}

eventType and notificationConfiguration attributes are not available on the above message.

I cannot identify if the object was added or removed without the 2 mentioned attributes.

Below is the code I used to display the message:

ProjectSubscriptionName subscriptionName =
                ProjectSubscriptionName.of(projectId, subscriptionId);

        // Instantiate an asynchronous message receiver.
        MessageReceiver receiver =
                (PubsubMessage message, AckReplyConsumer consumer) -> {
                    // Handle incoming message, then ack the received message.
                    System.out.println("Id: " + message.getMessageId());
                    System.out.println("Data: " + message.getData().toStringUtf8());
                    consumer.ack();
                };

Can someone let me know if I am missing something in configuring the storage bucket?

0 Answers
Related