示例#1
0
        private void Init(string subscriptionName)
        {
            Action <IModel> createRequestAndResponseQueuesAction = channel =>
            {
                var arguments = new Dictionary <string, object>();
                channel.QueueDeclare(_routeFinder.UniqueResponseQueue, true, false, true /* response queue will be deleted if client disconnected */, arguments);
                if (_routeFinder.CreateExchangeAndQueue)
                {
                    channel.QueueDeclare(_routeFinder.RequestQueue, true, false, false, arguments);
                    var requestExchange = _routeFinder.RequestExchangeName;
                    if (!string.IsNullOrEmpty(requestExchange))
                    {
                        channel.ExchangeDeclare(requestExchange, _routeFinder.RequestExchangeType, true, false, null);
                        channel.QueueBind(_routeFinder.RequestQueue, requestExchange, _routeFinder.RequestQueue /* Routing key is always same as requestQueueName*/);
                    }
                }
            };

            InternalDependencies.RpcQueueHelper.CreateQueues(_rabbitMqConnectionString, createRequestAndResponseQueuesAction);

            _tunnel.Subscribe <RpcResponse>(subscriptionName, ReceiveResponse);
        }