private void Init() { _tunnel = RabbitTunnel.Factory.Create(_rabbitMqConnectionString); _tunnel.SetRouteFinder(new RpcRouteFinderAdapter(_routeFinder)); _tunnel.SetSerializer(Global.DefaultSerializer); if (_routeFinder.CreateExchangeAndQueue) { var routingKey = _routeFinder.RequestQueue; var requestQueueName = _routeFinder.RequestQueue; var requestExchange = _routeFinder.RequestExchangeName; Action <IModel> createRequestQueues = channel => { var arguments = new Dictionary <string, object>(); var autoDeleteLoadBalanceRequestQueue = !string.IsNullOrEmpty(_serverId) && !string.IsNullOrEmpty(requestExchange); channel.QueueDeclare(requestQueueName, true, false, autoDeleteLoadBalanceRequestQueue, arguments); if (!string.IsNullOrEmpty(requestExchange)) { channel.ExchangeDeclare(requestExchange, _routeFinder.RequestExchangeType, true, false, null); channel.QueueBind(requestQueueName, requestExchange, routingKey); } }; InternalDependencies.RpcQueueHelper.CreateQueues(_rabbitMqConnectionString, createRequestQueues); } }
public BurrowRpcClientCoordinator(string rabbitMqConnectionString = null, IRpcRouteFinder routeFinder = null) { _rabbitMqConnectionString = InternalDependencies.RpcQueueHelper.TryGetValidConnectionString(rabbitMqConnectionString); _routeFinder = routeFinder ?? new DefaultRpcRouteFinder <T>(); _tunnel = RabbitTunnel.Factory.Create(_rabbitMqConnectionString); _tunnel.SetRouteFinder(new RpcRouteFinderAdapter(_routeFinder)); _tunnel.SetSerializer(Global.DefaultSerializer); var subscriptionName = typeof(T).Name; Init(subscriptionName); }