public static RoutesConfiguration FromCode(params Route[] routes) { var conf = new RoutesConfiguration(); if (routes != null && routes.Length > 0) conf._entries.AddRange(routes); return conf; }
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; }
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; }