Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why do GCP Pub/Sub messages have duplicated message_id and publish_time values?

I’m receiving messages from a pub/sub push subscription.

Here’s the payload of one such message in raw bytes:

REQUEST_BODY b'{"message":{"attributes":{"one":"two"},"data":"InN0dWZmIg==","messageId":"5481363137518973","message_id":"5481363137518973","publishTime":"2022-08-24T16:39:11.08Z","publish_time":"2022-08-24T16:39:11.08Z"},"subscription":"projects/my-project/subscriptions/my-subscription-name"}\n'

Notice that in the message there are two duplicated values:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • messageId vs message_id
  • publishTime vs publish_time

Now, I’m aware that some languages and styles prefer snake versus camel cases, and I’m not getting into what’s right

But objectively there should be only one for transmission over the wire, rather than sending BOTH!

I don’t care which gets used, but I do care that I’m getting charged for this bandwidth!!

Why does GCP do this, and can I turn it off?

>Solution :

I believe this is for backward compatibility. I think message_id was introduced earlier and then they changed it to messageId. In order to not break the existing code that someone may have written using message_id, they left it there and added messageId. Same thing applied to publishTime.

AFAIK you cannot turn it off.

Did some research on pricing. If I understand it correctly, you are not charged for Egress from pub/sub if your subscriber is in the same region as your pub/sub topic.

I am not sure about Throughput cost. Does it charge for the entire message body including the attributes added by Google or just for the data/attributes part (that you published)? I guess, someone from Google can answer that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading