Reputation: 2253
I am using the message_id and publish_time parameters as mentioned here to retrieve the message id and the time the message was published. While the message id is always received the timestamp is not always received. What is the reason??
Here is my callback function:
def callback(message):
print('Received message: {}'.format(message))
print ('message id is {}'.format(message.message_id))
print ('message just timestamp is {}'.format(message.publish_time))
print ('message timestamp is {}'.format(message.service_timestamp))
message.ack()
The output is:
Listening for messages on <google.cloud.pubsub_v1.SubscriberClient object at 0x107be4d50>
Received message: Message {
data: 'Tiemstamp??'
attributes: {}
}
message id is 47657545658108
Received message: Message {
data: 'Tiemstamp 1??'
attributes: {}
}
message id is 47661581138796
Received message: Message {
data: 'Tiemstamp 2??'
attributes: {}
}
message id is 47662293437069
message just timestamp is seconds: 1520024742
nanos: 52000000
Upvotes: 1
Views: 148
Reputation: 361
It appears that the lines that print out the timestamp never execute, rather than failing or showing empty timestamps. A simple explanation for this that I've seen a few times is that you have an older version of you code that does not have those lines still running in the background in your terminal. Do you think this might be the case?
Upvotes: 1