示例#1
0
        public override void Run()
        {
            _startSignal.WaitOne();
            var sw      = new Stopwatch();
            var numDone = 0;

            sw.Start();
            while (_running)
            {
                if (KafkaConnection.ReceivedBytes.TryDequeue(out byte[] data))
                {
                    DeserializedQueue.Enqueue(Serializer.Deserialize <User>(data));
                    numDone++;
                }
                if (DeserializedQueue.Count() >= NumExpected)
                {
                    _running = false;
                }
                _startSignal.WaitOne();
                Thread.Sleep(100);
            }
            sw.Stop();
            Log.WriteLogInfo($"{numDone} messages deserialized in {sw.ElapsedMilliseconds} ms.");
            _countdownEvent.Signal();
        }
示例#2
0
        static List <User> AvroDeserializeMessages(List <byte[]> msgs, AvroSerializer serializer, Logger log, ref Stopwatch sw)
        {
            sw.Reset();
            log.WriteLogInfo("Deserializing received messages.");
            sw.Start();
            var deserialized = new List <User>();

            foreach (var msg in msgs)
            {
                deserialized.Add(serializer.Deserialize <User>(msg));
            }
            sw.Stop();
            log.WriteLogInfo($"{deserialized.Count} messages deserialized in {sw.ElapsedMilliseconds} ms.");
            return(deserialized);
        }