Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PubSub auto-generate timestamps?

According to here: https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage

The timestamp field should not be populated when a publisher sends a message to the queue. So this leads me to think PubSub attaches a timestamp automatically whenever it gets a message from a publisher.

Is this correct?

like image 223
user20010203 Avatar asked Mar 11 '18 15:03

user20010203


People also ask

How long do messages stay in Pubsub?

The default message retention duration is 7 days and the default expiration period is 31 days. To create a subscription with retention of acked messages enabled, follow these steps: In the console, go to the Pub/Sub subscriptions page.

Is Pubsub message ID unique?

ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a PubsubMessage via a subscriptions.

How does cloud pub/sub deliver messages to endpoints?

The Pub/Sub server sends each message as an HTTPS request to the subscriber client at a pre-configured endpoint. This request is shown as a PushRequest in the image. The endpoint acknowledges the message by returning an HTTP success status code. A non-success response indicates that Pub/Sub must resend the messages.

How does Google pub/sub work?

Google Cloud Pub/Sub provides messaging between applications. Cloud Pub/Sub is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a "topic" and other applications can subscribe to that topic to receive the messages.


1 Answers

Yes, you got that correctly. This is what is implied with the following sentence (from the docs you linked):

publishTime: The time at which the message was published, populated by the server when it receives the topics.publish call.

You can test that yourself: if you go to the Explorer's API and publish to a topic using the pubsub.projects.topics.publish method, without giving a publishTime and then you pull using a subscription from that same topic (pubsub.projects.subscriptions.pull), the pulled message will have a publishTime.

Now, there is also a sentence in the docs regarding publishTime which seems a bit unclear to me:

It must not be populated by the publisher in a topics.publish call.

If you actually try to add a (correctly formatted) publishTime in your publish call, you will not get an error. Still, the actual publishTime attached to the message that you later pull is the one provided by the pub/sub service (i.e. the publish time you gave will simply be ignored).

like image 185
Lefteris S Avatar answered Jan 04 '23 08:01

Lefteris S