Esempio n. 1
0
        protected override void Connect()
        {
            Connection = Helpers.MakeConnection(BroadcastInfo.Host);
            Model      = Connection.CreateModel();

            Model.ExchangeDeclare(BroadcastInfo.Channel, ExchangeType.Fanout, false, false, null);

            PublishProps = Model.CreateBasicProperties();
            PublishProps.DeliveryMode = 1;

            if (!BroadcastInfo.SendOnly)
            {
                var q = Model.QueueDeclare("", false, false, true, null);
                Model.QueueBind(q.QueueName, BroadcastInfo.Channel, "");
                MyQueueName = q.QueueName;

                Consumer = new AsyncConsumer(new ConsumerInfo(BroadcastInfo.Host, MyQueueName, false, false, 4), DispatchMessage);

                if (!Waiter.Wait(3000, () => Consumer.IsConnected))
                {
                    throw new IOException();
                }
                if (MyState == State.Disposed) // could have been disposed while waiting
                {
                    return;
                }

                Consumer.IsConnectedChanged += isConnected => {
                    if (!isConnected)
                    {
                        ConnectionBroke();
                    }
                };
            }
        }
Esempio n. 2
0
 public SyncConsumer(ConsumerInfo ci)
 {
     Consumer = new AsyncConsumer(ci, msg => Messages.Enqueue(msg));
 }
Esempio n. 3
0
 public AsyncWorkQueueConsumer(WorkQueueInfo wq)
 {
     Consumer = new AsyncConsumer(new ConsumerInfo(wq.Host, wq.Name, true, wq.IsPersistent, 1), msg => Received.Fire(msg));
     Consumer.IsConnectedChanged += x => IsConnectedChanged.Fire(x);
 }