Skip to content

Commit

Permalink
Enable DTFx.AzureStorage v1.x backward compatibility support (#1120)
Browse files Browse the repository at this point in the history
* initial commit

* remove unnecessary using

* add comment

* update by comment
  • Loading branch information
nytian authored Jun 25, 2024
1 parent 0af3eca commit d75526f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/DurableTask.AzureStorage/Storage/QueueMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ class QueueMessage
public QueueMessage(CloudQueueMessage cloudQueueMessage)
{
this.CloudQueueMessage = cloudQueueMessage;
this.Message = this.CloudQueueMessage.AsString;
try
{
this.Message = this.CloudQueueMessage.AsString;
}
catch (FormatException)
{
// This try-catch block ensures forwards compatibility with DTFx.AzureStorage v2.x, which does not guarantee base64 encoding of messages (messages not encoded at all).
// Therefore, if we try to decode those messages as base64, we will have a format exception that will yield a poison message
// RawString is an internal property of CloudQueueMessage, so we need to obtain it via reflection.
System.Reflection.PropertyInfo rawStringProperty = typeof(CloudQueueMessage).GetProperty("RawString", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
this.Message = (string)rawStringProperty.GetValue(this.CloudQueueMessage);
}
this.Id = this.CloudQueueMessage.Id;
}

Expand Down

0 comments on commit d75526f

Please sign in to comment.