Search code examples
azureservicebusservicebusazure-servicebus-topicsazure-servicebus-subscriptions

Azure - ServiceBus: EnqueueTimeUtc is not accurate


I noticed that the message's EnqueueTimeUtc value is not accurate

I am using ServiceBus Topics and Subscribers for my system

The Sender side is written in .NET using "Microsoft.Azure.ServiceBus" Version="4.1.1" NuGet package Using the SendAsync() method to send messages to topic

The Subscriber side is written in Python using azure.servicebus.control_client (azure-servicebus version 0.50.3) Using the receive_subscription_message() method with peek_lock=True to receive messages

When I received the message on the subscriber side, I exported the 'EnqueuedTimeUtc' property from the received message and it's value was 'Tue, 21 Jul 2020 08:41:37 GMT'. But, I noticed that the time was not accurate (it was ~7 seconds later than current time) On the sender side, I added a log AFTER the message was sent and the timestamp of the log was '7/21/2020 08:41:29.5047754'

Both sender and subscriber were running on my local machine and the ServiceBus location is 'West US'

Am I missing something?


Solution

  • The one subtlety that may be missing here is that EnqueuedTimeUTC is set by the service, not the sender. Thus, both the sender and receiver clocks may be distinct (both from the service, and if they are on different machines, from each other) and as such I would not be surprised to observe limited skew as you've noted.

    Full disclosure, am one of the maintainers for the Python SB SDK, so feel free to let me know if more clarification is needed or if I've missed something; I hope this has been helpful!