示例#1
0
 public DeviceListDtoClient Enqueue(EnqueueMessagesDtoClient enqueueMessages)
 {
     return(new DeviceListDtoClient
     {
         DeviceIds =
             _persistentStorage.Enqueue(enqueueMessages.Messages.ConvertAll(m => new EnqueueItem
         {
             DeviceId = m.DeviceId,
             Payload = m.Payload,
             Timestamp = m.TimeStamp,
             SenderDeviceId = m.SenderDeviceId
         })).Select(r => r.Id).ToList()
     });
 }
示例#2
0
 public DeviceListDtoClient Enqueue(EnqueueMessagesDtoClient enqueueMessages)
 {
     return(new DeviceListDtoClient
     {
         DeviceIds =
             _messagingService.Enqueue(new EnqueueMessagesDto
         {
             Messages = enqueueMessages.Messages.ConvertAll(m => new EnqueueMessageDto
             {
                 DeviceId = m.DeviceId,
                 Payload = m.Payload,
                 TimeStamp = m.TimeStamp
             })
         }).DeviceIds
     });
 }
示例#3
0
文件: Program.cs 项目: kpocza/thriot
        private static void Enqueue()
        {
            var rndE     = new Random();
            var prevDate = DateTime.UtcNow;
            var prevEnci = 0;

            while (true)
            {
                var deviceIdSet = new HashSet <long>();
                for (int i = 0; i < EnqueueBatch; i++)
                {
                    deviceIdSet.Add(_deviceIds[rndE.Next(QueueSize)]);
                }

                var msgs = new EnqueueMessagesDtoClient
                {
                    Messages = deviceIdSet.Select(d => new EnqueueMessageDtoClient
                    {
                        DeviceId       = d,
                        Payload        = Enumerable.Range(1, 200).Select(i => (byte)i).ToArray(),
                        TimeStamp      = DateTime.UtcNow,
                        SenderDeviceId = new string('1', 32)
                    }).ToList()
                };

                _messagingServiceClient.Enqueue(msgs);

                Interlocked.Increment(ref _enc);
                Interlocked.Add(ref _encI, msgs.Messages.Count);

                if (_enc % _stepSize == 0)
                {
                    var now = DateTime.UtcNow;

                    Console.WriteLine("Enqueue: " + EnqueueBatch * _enc + " perf: " + (_encI - prevEnci) * TimeSpan.FromSeconds(1).Ticks / (now - prevDate).Ticks + " msg/s");

                    prevDate = now;
                    prevEnci = _encI;
                }
                Thread.Sleep(20);
            }
        }
示例#4
0
 public DeviceListDtoClient Enqueue(EnqueueMessagesDtoClient enqueueMessages)
 {
     return(_messagingServiceClient.Enqueue(enqueueMessages));
 }