Ejemplo n.º 1
0
        public virtual void SerializeObjects()
        {
            string         name = "test-SerializeObjects" + Salt;
            Queue <string> rq   = new Queue <string>(new string[] { "aaa", "aab", "abb", "bbb", "bbc", "bcc", "ccc" });
            Queue <string> wq   = new Queue <string>(new string[] { "aaa", "aab", "abb", "bbb", "bbc", "bcc", "ccc" });

            AbstractChannelsFactory fc = new RabbitMQChannelsFactory();

            Task tr = Task.Factory.StartNew(() => {
                using (IChannelReader <SerializeObjectsData> ch = fc.GetSubscribableChannel <SerializeObjectsData>(name).Subscribe())
                {
                    foreach (SerializeObjectsData item in ch.Enumerate())
                    {
                        Assert.AreEqual(item.OpId, rq.Dequeue());
                    }
                    Assert.IsTrue(ch.Drained);
                }
            });

            Task tw = Task.Factory.StartNew(() => {
                using (IChannelWriter <SerializeObjectsData> ch = fc.GetSubscribableChannel <SerializeObjectsData>(name))
                {
                    while (wq.Count > 0)
                    {
                        ch.Write(new SerializeObjectsData()
                        {
                            OpId = wq.Dequeue(), Status = "test", Message = "/messaggio/lungo/con/sbarre"
                        });
                    }
                    ch.Close();
                }
            });

            Task.WaitAll(tr, tw);
        }
Ejemplo n.º 2
0
 private void ChannelDrainedHandling(Exception obj)
 {
     if (obj is Exceptions.ChannelDrainedException)
     {
         if (_closeOnDrain)
         {
             _destination.Close();
         }
     }
 }
 public void Close()
 {
     _channel.Close();
 }
Ejemplo n.º 4
0
 public void Close()
 {
     _source.Close();
 }