Skip to content

Commit

Permalink
Merge pull request #43 from FoundatioFx/systemclock
Browse files Browse the repository at this point in the history
Adapt to system clock changes
  • Loading branch information
ejsmith authored Aug 31, 2024
2 parents c33252d + 40e16c5 commit fb7894a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />

<PackageReference Include="Foundatio" Version="10.7.1" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<PackageReference Include="Foundatio" Version="11.0.0" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />

<!-- NOTE: Forcing minimum for security patch. Remove once SDK versions are updated -->
<PackageReference Include="Microsoft.Rest.ClientRuntime" Condition="" Version="2.3.24" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Foundatio.AsyncEx;
using Foundatio.Extensions;
using Foundatio.Serializer;
using Foundatio.Utility;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Management;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -133,7 +132,7 @@ protected override Task PublishImplAsync(string messageType, object message, Mes
if (options.DeliveryDelay.HasValue && options.DeliveryDelay.Value > TimeSpan.Zero)
{
_logger.LogTrace("Schedule delayed message: {messageType} ({delay}ms)", messageType, options.DeliveryDelay.Value.TotalMilliseconds);
brokeredMessage.ScheduledEnqueueTimeUtc = SystemClock.UtcNow.Add(options.DeliveryDelay.Value);
brokeredMessage.ScheduledEnqueueTimeUtc = _timeProvider.GetUtcNow().UtcDateTime.Add(options.DeliveryDelay.Value);
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions src/Foundatio.AzureServiceBus/Queues/AzureServiceBusQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Foundatio.AzureServiceBus.Queues;
using Foundatio.Extensions;
using Foundatio.Serializer;
using Foundatio.Utility;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Core;
using Microsoft.Azure.ServiceBus.Management;
Expand Down Expand Up @@ -147,7 +146,7 @@ protected override async Task<string> EnqueueImplAsync(T data, QueueEntryOptions

await _queueSender.SendAsync(brokeredMessage).AnyContext();

var entry = new QueueEntry<T>(brokeredMessage.MessageId, brokeredMessage.CorrelationId, data, this, SystemClock.UtcNow, 0);
var entry = new QueueEntry<T>(brokeredMessage.MessageId, brokeredMessage.CorrelationId, data, this, _timeProvider.GetUtcNow().UtcDateTime, 0);
entry.SetLockToken(brokeredMessage);
foreach (var property in brokeredMessage.UserProperties)
entry.Properties.Add(property.Key, property.Value.ToString());
Expand Down
10 changes: 5 additions & 5 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<NoWarn>$(NoWarn);CS1591;NU1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />

<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" PrivateAssets="All" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" PrivateAssets="All" />

<PackageReference Include="Foundatio.TestHarness" Version="10.7.1" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<PackageReference Include="Foundatio.TestHarness" Version="11.0.0" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<ProjectReference Include="..\..\..\Foundatio\src\Foundatio.TestHarness\Foundatio.TestHarness.csproj" Condition="'$(ReferenceFoundatioSource)' == 'true'" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AzureServiceBusQueueTests(ITestOutputHelper output) : base(output)
Log.SetLogLevel<AzureServiceBusQueue<SimpleWorkItem>>(LogLevel.Trace);
}

protected override IQueue<SimpleWorkItem> GetQueue(int retries = 1, TimeSpan? workItemTimeout = null, TimeSpan? retryDelay = null, int[] retryMultipliers = null, int deadLetterMaxItems = 100, bool runQueueMaintenance = true)
protected override IQueue<SimpleWorkItem> GetQueue(int retries = 1, TimeSpan? workItemTimeout = null, TimeSpan? retryDelay = null, int[] retryMultipliers = null, int deadLetterMaxItems = 100, bool runQueueMaintenance = true, TimeProvider timeProvider = null)
{
string connectionString = Configuration.GetConnectionString("AzureServiceBusConnectionString");
if (String.IsNullOrEmpty(connectionString))
Expand All @@ -44,6 +44,7 @@ protected override IQueue<SimpleWorkItem> GetQueue(int retries = 1, TimeSpan? wo
RequiresSession = false,
Retries = retries,
RetryPolicy = retryPolicy,
TimeProvider = timeProvider,
WorkItemTimeout = workItemTimeout.GetValueOrDefault(TimeSpan.FromMinutes(5)),
LoggerFactory = Log
});
Expand Down

0 comments on commit fb7894a

Please sign in to comment.