protected internal override void Apply(IManagementClient managementClient) { var destinationName = ToQueueDeclared ? ToQueue : ToExchange; _log.Info($"Declaring binding from '{FromExchange}' to '{destinationName}'"); _log.Info($" RoutingKey = {RoutingKey}"); var virtualHost = managementClient.GetVhost(VirtualHost); var exchange = managementClient.GetExchange(FromExchange, virtualHost); var info = new BindingInfo(RoutingKey); if (ToQueueDeclared) { var toQueue = managementClient.GetQueue(ToQueue, virtualHost); managementClient.CreateBinding(exchange, toQueue, info); } if (ToExchangeDeclared) { var toExchange = managementClient.GetExchange(ToExchange, virtualHost); managementClient.CreateBinding(exchange, toExchange, info); } _log.Info($"Finished declaring binding from '{FromExchange}' to '{destinationName}'"); }
public void Should_be_able_to_get_an_individual_exchange_by_name() { var vhost = new Vhost { Name = vhostName }; var exchange = managementClient.GetExchange(testExchange, vhost); exchange.Name.ShouldEqual(testExchange); }
protected internal override void Apply(IManagementClient managementClient) { _log.Info($"Moving messages from queue '{SourceQueue}' to exchange '{DestinationExchange}'"); if (MessageTypeDeclared) { _log.Info($" MessageType = {MessageType}"); } var virtualHost = managementClient.GetVhost(VirtualHost); var sourceQueue = managementClient.GetQueue(SourceQueue, virtualHost); var destinationExchange = managementClient.GetExchange(DestinationExchange, virtualHost); var messages = managementClient.GetMessagesFromQueue(sourceQueue, new GetMessagesCriteria(long.MaxValue, false)); foreach (var message in messages) { if (MessageTypeDeclared) { message.Properties["type"] = MessageType; } var properties = message.Properties .ToDictionary(property => property.Key, property => property.Value); managementClient.Publish(destinationExchange, new PublishInfo(properties, "#", message.Payload, message.PayloadEncoding)); } }
protected internal override void Apply(IManagementClient managementClient) { _log.Info($"Deleting exchange '{Name}' from '{VirtualHost}'"); var virtualHost = managementClient.GetVhost(VirtualHost); var exchange = managementClient.GetExchange(Name, virtualHost); managementClient.DeleteExchange(exchange); _log.Info($"Finished deleting exchange '{Name}' from '{VirtualHost}'"); }