private void TryPublish(MessageServiceItem item)
        {
            var serializeObject = JsonConvert.SerializeObject(item.Message);

            socket.SendTo(Encoding.ASCII.GetBytes(serializeObject), serializeObject.Length, SocketFlags.None, item.EndPoint);
            item.Message.Header.PublishTries++;
        }
 public void AddItem(MessageServiceItem item)
 {
     lock (Lock)
     {
         list.Add(item);
     }
 }
        public bool TryGetNextItem(out MessageServiceItem item)
        {
            lock (Lock)
            {
                item = default(MessageServiceItem);
                if (!list.Any())
                {
                    return(false);
                }

                index++;
                index = index % list.Count;
                item  = list[index];
                return(true);
            }
        }