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?
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).
They do generate using the publishTime. However on cases where there are multiple publishers publishing to Pub-Sub, you could attach a timestamp to every event in the publisher.
https://cloud.google.com/pubsub/docs/ordering
Related
I want to get notified (through email of slack channel) for every Exception occurence in my GAP services.
When I'm trying to create a notification through GCP Error Reporting, it seems like I'm being able to get one notification per incident (and not per occurrence), and that it is also being queried only once a day/hour/month.
I've also tried to create a policy in GCP Logs Monitoring based on log severity, but of course I don't get notified only for exceptions, and the slack notifications just announce that a threshold is being passed, without the actual data I want to get by push.
Any way I can make Error Reporting notify me per each occurance?
Is there any other internal tool by GCP that notify when event occurs? or should I use an external tool such as Epsagon/Operations (formally Stackdriver)?
So it seems like there is no availability for getting a pushed event on each exception occurrence, and since I didn't want to query it by pull (with ereport) or to get only new exceptions (through Stackdriver), I had to go with an external service such as Datadog.
I'm building a discord bot with discord.py.
I'm writing a test that adds a reaction to a Message using the add_reaction method.
My Message instance is not reflecting the changes, though they are visible in the server. I've added a refresh of the instance to the test to get around it.
My question is: do the instances of messages (or other classes) need to be refreshed on each use to match the most recent state in the guild or do they sync on their own?
Thanks!
No, it doesn't update automatically. You'll have to use channel.history to read the updated messages. More here.
As a subscriber to a pubsub topic, is it possible for me to find out what time a message was received by pubsub? That is, can a subscriber that has just received a message find out what time the corresponding publisher published the message?
This is possible with a pull subscriber. Use the publishTime field of PubsubMessage.
If you are using a client library, read the library docs on how to access this. For example, with the python client lib, it is accessible via the publish_time field on the Message class.
What is the best way in Backbone.JS to determine if a model was deleted on the server in the meantime?
I need this for a simple webapp where multiple users can update or delete items, and, even if at the time the page was loaded a model did exist, by the time the other user is interacting with it it might have been already deleted.
Include a revision number (or something similar) in your model, then on the server-side, when a client attempts to modify a resource you first verify that the revision number included matches what the server has. If it does, update the resource and then respond with the resource and the new revision number. If it doesn't, then respond with a 409 status code. If the client receives a 409 response, then it should pull the latest changes to the resource from the server and then attempt to push it's changes again with the updated revision number.
I'm writing an application that synchronize emails (inbox only) from an IMAP server. For that I'm using javamail and I have performance issue. When I want to refresh my emails, I fetch all messages in inbox, and it takes several minutes. :(
So I would like to fetch only messages that were modified since the last time I refreshed emails. I found how to fetch messages received or sent since a date, but what I want to do is slightly different. It is possible to change the state of a very old message (unread to read). In this case the modification date is recent but received or send date is old.
Any idea ?
Regards,
Quentin
You can't change the content of an old message, but you can change the flags. You can fetch all the flags for all messages and compare them with your cached copy of the flags. (There are IMAP extensions that help with this, but many IMAP servers don't support them and JavaMail doesn't support them.)
Use the Folder.fetch method to fetch all the flags in one operation, then iterate over the Message objects and compare the flags.