Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #265 from Jonathan-hickey-cko/main
Browse files Browse the repository at this point in the history
Upgrading AWS Package versions and Fixing SqsBatchedDispatcher delay
  • Loading branch information
Im5tu authored Apr 8, 2021
2 parents 65dd6eb + e296897 commit 378560c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/OpenMessage.AWS.SNS/OpenMessage.AWS.SNS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.5.0.29" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.9" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/OpenMessage.AWS.SQS/OpenMessage.AWS.SQS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SQS" Version="3.5.0.28" />
<PackageReference Include="AWSSDK.SQS" Version="3.7.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.9" />
</ItemGroup>

Expand Down
9 changes: 6 additions & 3 deletions src/OpenMessage.AWS.SQS/SqsBatchedDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ public override async Task DispatchAsync(Message<T> message, CancellationToken c
{
Id = Guid.NewGuid().ToString("N"),
MessageAttributes = GetMessageProperties(message),
DelaySeconds = DelaySeconds(message),
MessageBody = json
};

var delay = DelaySeconds(message);
if (delay.HasValue)
request.DelaySeconds = delay.Value;

var msg = new SendSqsMessageCommand
{
Message = request,
Expand All @@ -81,14 +84,14 @@ public override async Task DispatchAsync(Message<T> message, CancellationToken c
}
}

private static int DelaySeconds(Message<T> message)
private static int? DelaySeconds(Message<T> message)
{
if (message is ISupportSendDelay delay && delay.SendDelay > TimeSpan.Zero)
{
return Math.Min(MaximumSqsDelaySeconds, (int) delay.SendDelay.TotalSeconds);
}

return 0;
return null;
}

private Dictionary<string, MessageAttributeValue> GetMessageProperties(Message<T> message)
Expand Down

0 comments on commit 378560c

Please sign in to comment.