Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to cast UInt64 to DateTime at Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.get_LockedUntil() #68

Open
lars-houtman opened this issue Nov 12, 2024 · 2 comments

Comments

@lars-houtman
Copy link

lars-houtman commented Nov 12, 2024

When receiving a message via a Processor, the value in the LockedUntil member of the message arriving in the ServiceBus SDK is not castable to a DateTime as it is a UInt64:
This happens here:
image

The value is brought in like this:
image

Causing the following stacktrace:

System.InvalidCastException: Unable to cast object of type 'System.UInt64' to type 'System.DateTime'.
   at Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.get_LockedUntil()
   at Azure.Messaging.ServiceBus.CancellationTokenSourceExtensions.CancelAfterLockExpired(CancellationTokenSource cancellationTokenSource, ServiceBusReceivedMessage receivedMessage)
   at Azure.Messaging.ServiceBus.ProcessMessageEventArgs..ctor(ServiceBusReceivedMessage message, ReceiverManager manager, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.ProcessMessageEventArgs..ctor(ServiceBusReceivedMessage message, ReceiverManager manager, String identifier, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.ReceiverManager.ConstructEventArgs(ServiceBusReceivedMessage message, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.ReceiverManager.ProcessOneMessage(ServiceBusReceivedMessage triggerMessage, CancellationToken cancellationToken)

This leads to the message being sent to the error eventhandler immediately without being able to process it.

If you require more info, please let me know

@lars-houtman
Copy link
Author

Update: an "actual" servicebus returns the value in a string format:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant