protected Exchange GetExchange(string exchangeName) { var exchanges = _managementClient.GetExchanges(); var exchange = exchanges.SingleOrDefault(q => q.Name == exchangeName); return(exchange); }
public void Should_get_exchanges() { var exchanges = managementClient.GetExchanges(); foreach (Exchange exchange in exchanges) { Console.Out.WriteLine("exchange.Name = {0}", exchange.Name); } }
public Topology Parse(IManagementClient client, Vhost virtualHost) { var topology = new Topology(); foreach (var exchange in client.GetExchanges()) { if (!IsSystemExchange(exchange.Name)) { var modelExchange = new Model.Exchange { Name = exchange.Name, ExchangeType = ExchangeTypeMap[exchange.Type], Durable = exchange.Durable, }; MapArguments(exchange.Arguments, modelExchange.Arguments); topology.Exchanges.Add(modelExchange); } } foreach (var queue in client.GetQueues()) { if (!IsSystemQueue(queue)) { var modelQueue = new Model.Queue { Name = queue.Name, Durable = queue.Durable }; MapArguments(queue.Arguments, modelQueue.Arguments); foreach (var binding in client.GetBindingsForQueue(queue)) { if (!IsSystemBinding(binding)) { var modelBinding = new Model.Binding { Exchange = binding.Source, RoutingKey = binding.RoutingKey }; MapArguments(binding.Arguments, modelBinding.Arguments); modelQueue.Bindings.Add(modelBinding); } } topology.Queues.Add(modelQueue); } } return topology; }
public void CleanUp(IManagementClient client) { foreach (var queue in client.GetQueues()) { Console.Out.WriteLine("Deleting Queue: {0}", queue.Name); client.DeleteQueue(queue); } foreach (var exchange in client.GetExchanges()) { if (!exchange.Name.StartsWith("amp.")) { Console.Out.WriteLine("Deleting Exchange: {0}", exchange.Name); client.DeleteExchange(exchange); } } }