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

Delay decoding a message's contents in DTFx.AzureStorage #1110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/DurableTask.AzureStorage/Storage/QueueMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,27 @@ class QueueMessage
public QueueMessage(CloudQueueMessage cloudQueueMessage)
{
this.CloudQueueMessage = cloudQueueMessage;
this.Message = this.CloudQueueMessage.AsString;
this.Id = this.CloudQueueMessage.Id;
}

public QueueMessage(string message)
{
this.CloudQueueMessage = new CloudQueueMessage(message);
this.Message = this.CloudQueueMessage.AsString;
this.Id = this.CloudQueueMessage.Id;
}

public CloudQueueMessage CloudQueueMessage { get; }

public string Message { get; }
public string Message {
get
{
// Obtaining the contents of a queueMessage can yield de-serializations exceptions.
// For example, if the message was encoded with a different encoding than the one used to decode it, this will throw.
// There are many cases where we don't actually need the message contents, such as when we're just trying to peek at the message's Age
// in the ScaleController. Therefore, we delay the decoding of the message until it's actually needed.
return this.CloudQueueMessage.AsString;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this value be cached, to avoid deserializing the CloudQueueMessage multiple times?

}
}

public string Id { get; }

Expand Down