-
Notifications
You must be signed in to change notification settings - Fork 325
Add simple poison message handling for Azure Storage #1063
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
Changes from 34 commits
22531fe
748b279
40a00dd
b1b7fba
b1808a1
45d523b
82e3531
adf4579
d20bb7e
40baca0
f896364
cef1410
eeea159
961d64b
5dfe896
4a25c5b
8afbfc2
9057bfd
6866828
b0d739c
71e0b36
5934076
a94cc4e
37dbac4
865aa20
57bb966
6c3bb79
b15dbb5
cbb8274
2acadbe
16f38f1
74dc0f7
584cf8d
51978a0
65c29c4
de7e46b
a8b24e5
a746b1e
d219ffa
b2e1f0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ---------------------------------------------------------------------------------- | ||
|
|
||
| #nullable enable | ||
| namespace DurableTask.AzureStorage | ||
| { | ||
| using System; | ||
|
|
@@ -50,7 +50,7 @@ public MessageManager( | |
| { | ||
| this.settings = settings; | ||
| this.azureStorageClient = azureStorageClient; | ||
| this.blobContainer = this.azureStorageClient.GetBlobContainerReference(blobContainerName); | ||
| this.blobContainer = this.azureStorageClient?.GetBlobContainerReference(blobContainerName); | ||
| this.taskMessageSerializerSettings = new JsonSerializerSettings | ||
| { | ||
| TypeNameHandling = TypeNameHandling.Objects, | ||
|
|
@@ -61,9 +61,13 @@ public MessageManager( | |
| #endif | ||
| }; | ||
|
|
||
| if (this.settings.UseDataContractSerialization) | ||
| JsonSerializer newtonSoftSerializer = JsonSerializer.Create(taskMessageSerializerSettings); | ||
|
|
||
| if (this.settings.UseDataContractSerialization) // for hotfix to work, set setting to `true` | ||
|
||
| { | ||
| this.taskMessageSerializerSettings.Converters.Add(new DataContractJsonConverter()); | ||
| var dataConverter = new DataContractJsonConverter(); | ||
| dataConverter.alternativeSerializer = newtonSoftSerializer; | ||
| this.taskMessageSerializerSettings.Converters.Add(dataConverter); | ||
| } | ||
|
|
||
| // We _need_ to create the Json serializer after providing the data converter, | ||
|
|
@@ -122,17 +126,18 @@ public async Task<string> SerializeMessageDataAsync(MessageData messageData) | |
| /// <returns>Actual string representation of message.</returns> | ||
| public async Task<string> FetchLargeMessageIfNecessary(string message) | ||
| { | ||
| if (TryGetLargeMessageReference(message, out Uri blobUrl)) | ||
| if (TryGetLargeMessageReference(message, out Uri? blobUrl)) | ||
| { | ||
| return await this.DownloadAndDecompressAsBytesAsync(blobUrl); | ||
| // we know blobUrl is not null because TryGetLargeMessageReference returned true | ||
| return await this.DownloadAndDecompressAsBytesAsync(blobUrl!); | ||
| } | ||
| else | ||
| { | ||
| return message; | ||
| } | ||
| } | ||
|
|
||
| internal static bool TryGetLargeMessageReference(string messagePayload, out Uri blobUrl) | ||
| internal static bool TryGetLargeMessageReference(string messagePayload, out Uri? blobUrl) | ||
| { | ||
| if (Uri.IsWellFormedUriString(messagePayload, UriKind.Absolute)) | ||
| { | ||
|
|
@@ -318,6 +323,7 @@ public async Task<int> DeleteLargeMessageBlobs(string sanitizedInstanceId) | |
| return storageOperationCount; | ||
| } | ||
| } | ||
| #nullable disable | ||
|
|
||
| #if NETSTANDARD2_0 | ||
| class TypeNameSerializationBinder : ISerializationBinder | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is here because I added nullable analysis