Exemplo n.º 1
0
        private IExchange BindDefaultExchange(IQueue queue)
        {
            var exchange = Exchange.GetDefault();

            queue.BindTo(exchange);
            return(exchange);
        }
        public override void StartListening()
        {
            _exchange = Exchange.DeclareFanout(Configuration.ExchangeName);

            _queue = Configuration.QueueName == null
                ? Queue.DeclareTransient()
                : Queue.DeclareTransient(Configuration.QueueName);

            _queue.BindTo(_exchange, "#");
            _bus.Subscribe<RabbitMqMessageWrapper>(_queue,
                (msg, messageReceivedInfo) =>
                    Task.Factory.StartNew(() =>  OnMessage(msg.Body)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes RabbitMQ Queue
        /// </summary>
        private IQueue InitializeQueue(IExchange exchange, string queueName, string routingKey)
        {
            try
            {
                // Initialize specified Queue
                IQueue queue = Queue.Declare(false, true, false, queueName, null);

                // Bind Queue to already initialized Exchange with the specified Routing Key
                queue.BindTo(exchange, routingKey);
                return(queue);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "InitializeQueue");
                return(null);
            }
        }