public async Task Process(SmsDto message) { if (message == null) { return; } var waitTime = new Random().Next(5, 10) * 100; await Task.Delay(waitTime); await _messageQueue.Enqueue(new LogSmsDto { Id = message.Id, Message = message.Message, PhoneNumber = message.PhoneNumber, UserId = message.UserId }); }
public async Task Process(DemoCounterModel state, CancellationToken cancellationToken) { var timer = new Stopwatch(); timer.Start(); var tasksList = new List <SmsDto>(); var task = new SmsDto(userId: Guid.NewGuid().ToString(), phoneNumber: "6992731575", message: $"Transaction '{Guid.NewGuid()}' took place."); for (var i = 0; i < 5; i++) { tasksList.Add(task); } var waitTime = new Random().Next(15, 20) * 1000; await Task.Delay(waitTime, cancellationToken); await _messageQueue.EnqueueRange(tasksList, visibilityWindow : TimeSpan.FromMinutes(1)); timer.Stop(); _logger.LogDebug("{HandlerName} took {ExecutionTime}ms to execute.", nameof(LoadAvailableAlertsJobHandler), timer.ElapsedMilliseconds); }