Ejemplo n.º 1
0
        public void Unsubscribe(IMessageListener listener)
        {
            if (_attachedListener.Listener != listener)
            {
                throw new Exception("Unknown listener");
            }

            foreach (var exchange in _attachedListener.Exchanges)
            {
                bus.Advanced.BindingDelete(new Binding(queue, exchange, "#"));
            }

            bus.Advanced.QueuePurge(queue);

            _attachedListener = null;
        }
Ejemplo n.º 2
0
        public void Subscribe(IMessageListener listener)
        {
            if (_attachedListener != null)
            {
                throw new Exception("Only 1 listener at a time");
            }

            _attachedListener = new AttachedListener
            {
                Listener  = listener,
                Exchanges = listener.InterestedIn
                            .Select(t => bus.Advanced.Conventions.ExchangeNamingConvention(t))
                            .Select(name => bus.Advanced.ExchangeDeclare(name, ExchangeType.Topic))
                            .ToList()
            };

            foreach (var exchange in _attachedListener.Exchanges)
            {
                bus.Advanced.Bind(exchange, queue, "#");
            }
        }