public void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body) { Debug.WriteLine(String.Format("Recieved: {0}", Encoding.UTF8.GetString(body))); RabbitMQ.JSONDogBreed o = JsonConvert.DeserializeObject <RabbitMQ.JSONDogBreed>(Encoding.UTF8.GetString(body)); o.ReceivedTimeStamp = Environment.TickCount; // keep track of this data this.AddDogBreed(o); }
private void AddDogBreed(RabbitMQ.JSONDogBreed ageGender) { lock (_dogBreed) { _dogBreed.Add(ageGender); // remove - lean up our collection of DogBreeds for (int i = _dogBreed.Count - 1; i >= 0; i--) { if (Environment.TickCount - _dogBreed[i].ReceivedTimeStamp > DATA_LIFESPAN_MS) { _dogBreed.RemoveAt(i); } } } }