protected override void Load(ContainerBuilder builder) { // Registers all consumers with our container builder.RegisterConsumers(_assembliesToScan); // Creates our bus from the factory and registers it as a singleton against two interfaces builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc => { var componentContext = c.Resolve<IComponentContext>(); var host = sbc.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h => { // Configure your host h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]); h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]); }); sbc.ReceiveEndpoint(host, ConfigurationManager.AppSettings["MyMessageQueueName"], e => { // Configure your consumer(s) e.PrefetchCount = 4; e.LoadFrom(componentContext.Resolve<ILifetimeScope>()); }); })) .SingleInstance() .As<IBusControl>() .As<IBus>(); }
public void Registration_extension_method_for_consumers() { var builder = new ContainerBuilder(); builder.RegisterConsumers(System.Reflection.Assembly.GetExecutingAssembly()); var container = builder.Build(); Assert.That(container.IsRegistered<TestConsumer>(), Is.True); }
protected override void Load(ContainerBuilder builder) { builder.RegisterConsumers(_assembliesToScan); // Creates our bus from the factory and registers it as a singleton against two interfaces builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc => sbc.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h => { h.Username(ConfigurationManager.AppSettings["RabbitMQUsername"]); h.Password(ConfigurationManager.AppSettings["RabbitMQPassword"]); }))) .As<IBusControl>() .As<IBus>() .SingleInstance(); }
public async Task Throw_them_under_the_bus() { var builder = new ContainerBuilder(); builder.RegisterConsumers(Assembly.GetExecutingAssembly()); builder.RegisterType<InMemorySagaRepository<SimpleSaga>>() .As<ISagaRepository<SimpleSaga>>() .SingleInstance(); var container = builder.Build(); var busControl = Bus.Factory.CreateUsingInMemory(x => { x.ReceiveEndpoint("input_queue", e => e.LoadFrom(container)); }); var busHandle = await busControl.StartAsync(); await busHandle.Ready; await busHandle.StopAsync(); }
protected override void Load(ContainerBuilder builder) { builder.RegisterConsumers(typeof(SendDocketLinkNotificationConsumer).Assembly); }