/// <summary> /// Defines a fanout exchange that will broadcast messages to all bound message queues. /// This should be used for notification type messages where the subscriber only cares /// about current occurring messages and not about prior missed messages that happened /// when they were offline. /// /// https://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-fanout /// </summary> /// <param name="name">The name of the exchange.</param> /// <param name="busName">The bus name key used to lookup connection.</param> /// <param name="settings">Optional delegate called allowing caller to set /// additional exchange properties.</param> /// <typeparam name="TMessage">The domain-event type associated with the exchange.</typeparam> protected void DefineFanoutExchange <TMessage>(string name, string busName, Action <ExchangeMeta <TMessage> > settings = null) where TMessage : IDomainEvent { var exchange = ExchangeMeta.Define <TMessage>(busName, name, ExchangeType.Fanout, config => { config.IsAutoDelete = true; config.IsDurable = false; config.IsPersistent = false; config.IsPassive = false; }); _exchanges.Add(exchange); settings?.Invoke(exchange); }
public void CanSpecifyExchangeSettings_InConfiguration() { ContainerFixture.Test(fixture => { fixture.Arrange .Configuration(TestSetup.AddValidBusConfigWithExchangeSettings) .Container(c => { c.WithRabbitMqHost(); }) .Assert.PluginModule <MockBusModule>(m => { var exchangeMeta = ExchangeMeta.Define("TestBus1", "TestExchangeName", ExchangeType.Direct); m.ApplyExchangeSettings(exchangeMeta); Assert.True(exchangeMeta.IsPassive); Assert.Equal("TestAltExchangeName", exchangeMeta.AlternateExchangeName); Assert.Equal("TestContentType", exchangeMeta.ContentType); Assert.Equal(10000, exchangeMeta.CancelRpcRequestAfterMs); }); }); }
public QueueMeta CreateQueueMeta(SubscriberQueueAttribute attribute) { var exchange = ExchangeMeta.Define(attribute.BusName, attribute.ExchangeName, ExchangeType.Fanout, config => { config.IsAutoDelete = true; config.IsDurable = false; config.IsPassive = false; config.IsPersistent = false; }); var queue = QueueMeta.Define(attribute.QueueName, exchange, config => { config.IsAutoDelete = true; config.IsDurable = false; config.IsPassive = false; config.IsExclusive = true; config.AppendUniqueId = true; }); return(queue); }