/// <inheritdoc /> public QueueOutputMessages Handle(SendMessageCommandBatch commandSend) { var rc = new ConcurrentBag <IQueueOutputMessage>(); var splitList = commandSend.Messages.Partition(_sendBatchSize.BatchSize(commandSend.Messages.Count)) .Select(x => x.ToList()) .ToList(); Parallel.ForEach(splitList, m => { var meta = _serializer.InternalSerializer.ConvertToBytes( new RedisMetaData(_unixTimeFactory.Create().GetCurrentUnixTimestampMilliseconds())); foreach (var s in SendMessages(m, meta)) { rc.Add(s); } }); return(new QueueOutputMessages(rc.ToList())); }
/// <inheritdoc /> public async Task <QueueOutputMessages> Handle(SendMessageCommandBatch commandSend) { var rc = new ConcurrentBag <IQueueOutputMessage>(); var splitList = commandSend.Messages.Partition(_sendBatchSize.BatchSize(commandSend.Messages.Count)) .Select(x => x.ToList()) .ToList(); foreach (var m in splitList) { var meta = _serializer.InternalSerializer.ConvertToBytes(new RedisMetaData(_unixTimeFactory.Create().GetCurrentUnixTimestampMilliseconds())); var sentMessages = await SendMessagesAsync(m, meta).ConfigureAwait(false); foreach (var s in sentMessages) { rc.Add(s); } } return(new QueueOutputMessages(rc.ToList())); }