Esempio n. 1
0
        public override Task ConsumeAsync(ConsumedMessage <Request> message)
        {
            return(Task.Factory
                   .StartNew(() =>
            {
                Console.WriteLine("[{0}]received '{1}' by '{2}' with correlation id {3}",
                                  message.ConsumerTag,
                                  message.Headers.MessageId,
                                  GetType().Name,
                                  message.Headers.CorrelationId);

                var exchange = _broker.DeclareDirectExchange(message.Headers
                                                             .ReplyConfiguration
                                                             .ExchangeName);
                var queue = _broker.DeclareQueue(message.Headers
                                                 .ReplyConfiguration
                                                 .RoutingKey);
                _broker.DeclareExchangeBinding(exchange,
                                               queue,
                                               message.Headers.ReplyConfiguration.RoutingKey);

                var outboundMessage = new OutboundMessage <Response>(new Response
                {
                    BarBar = message.Content.Bar * 2
                });
                outboundMessage.SetCorrelationId(message.Headers.CorrelationId);
                _connection.PublishAsync(outboundMessage,
                                         exchange,
                                         message.Headers.ReplyConfiguration.RoutingKey);
            }));
        }
Esempio n. 2
0
        private static Queue BindDurableQueue(IBroker broker, String queueName, Exchange exchange)
        {
            var queue = broker.DeclareDurableQueue(queueName);

            broker.DeclareExchangeBinding(exchange, queue, RoutingKey);
            return(queue);
        }
Esempio n. 3
0
 private static Queue BindDurableQueue(IBroker broker, String queueName, Exchange exchange)
 {
     var queue = broker.DeclareDurableQueue(queueName);
     broker.DeclareExchangeBinding(exchange, queue, RoutingKey);
     return queue;
 }