コード例 #1
0
        public static RoutesConfiguration FromCode(params Route[] routes)
        {
            var conf = new RoutesConfiguration();
            if (routes != null && routes.Length > 0)
                conf._entries.AddRange(routes);

            return conf;
        }
コード例 #2
0
        public static RoutesConfiguration FromConfiguration()
        {
            var section = ConfigurationManager.GetSection("RoutingConfigurationSection") as RoutingConfigurationSection;
            if(section == null)
                return new RoutesConfiguration();

            var routingConfiguration = new RoutesConfiguration();

            foreach (RouteElement route in section.Routes)
            {
                routingConfiguration._entries.Add(new Route(route.QueueName, route.ExchangeName, route.RoutingKey));
            }

            return routingConfiguration;
        }
コード例 #3
0
ファイル: Rabbit.cs プロジェクト: GasiorowskiPiotr/NRabbitBus
        public Rabbit SetupRouting(RoutesConfiguration routesConfiguration)
        {
            if(Log.IsInfoEnabled)
                Log.Info("Setting up Routing...");

            var channel = ComponentLocator.Current.Get<IModel>();

            foreach (var routingEntry in routesConfiguration.Routes)
            {
                if(Log.IsDebugEnabled)
                    Log.Debug("Binding Queue: {0} to Exchange: {1} by Routing Key: {2}", routingEntry.QueueName, routingEntry.ExchangeName, routingEntry.RoutingKey);

                channel.QueueBind(routingEntry.QueueName, routingEntry.ExchangeName, routingEntry.RoutingKey);
            }

            if (Log.IsInfoEnabled)
                Log.Info("Routing set up.");

            return this;
        }