Skip to content

Commit

Permalink
Throw if fail to deserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
vansha committed Mar 15, 2024
1 parent 7ac3c5e commit 376bd3e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions AzureBatchQueue/MessageQueue.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using Azure;
using Azure.Storage.Blobs;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;
Expand Down Expand Up @@ -37,11 +36,14 @@ public MessageQueue(string connectionString, string queueName,

public string Name => queue.Name;

public async Task Send(T item, TimeSpan? visibilityTimeout = null, CancellationToken ct = default)
public async Task Send(T item, TimeSpan? visibilityTimeout = null, bool doubleCheckSerialization = false, CancellationToken ct = default)
{
var (data, _) = await SerializeAndOffloadIfBig(item, ct: ct);

var (data, offloaded) = await SerializeAndOffloadIfBig(item, ct: ct);
await queue.SendMessageAsync(new BinaryData(data), visibilityTimeout ?? TimeSpan.Zero, null, ct);

// Don't ask. Checking our sanity
if (!offloaded && doubleCheckSerialization)
serializer.Deserialize(data);
}

public async Task DeleteMessage(MessageId id, CancellationToken ct = default)
Expand Down

0 comments on commit 376bd3e

Please sign in to comment.