Skip to content

Commit

Permalink
Adapt to SystemClock removal
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Aug 7, 2024
1 parent c33252d commit 45f3e09
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
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);

Check failure on line 135 in src/Foundatio.AzureServiceBus/Messaging/AzureServiceBusMessageBus.cs

View workflow job for this annotation

GitHub Actions / build / build

The name '_timeProvider' does not exist in the current context

Check failure on line 135 in src/Foundatio.AzureServiceBus/Messaging/AzureServiceBusMessageBus.cs

View workflow job for this annotation

GitHub Actions / build / build

The name '_timeProvider' does not exist in the current context
}
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);

Check failure on line 149 in src/Foundatio.AzureServiceBus/Queues/AzureServiceBusQueue.cs

View workflow job for this annotation

GitHub Actions / build / build

The name '_timeProvider' does not exist in the current context

Check failure on line 149 in src/Foundatio.AzureServiceBus/Queues/AzureServiceBusQueue.cs

View workflow job for this annotation

GitHub Actions / build / build

The name '_timeProvider' does not exist in the current context
entry.SetLockToken(brokeredMessage);
foreach (var property in brokeredMessage.UserProperties)
entry.Properties.Add(property.Key, property.Value.ToString());
Expand Down
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 45f3e09

Please sign in to comment.