Esempio n. 1
0
        private static void LoadMassTransitImplementation(
            Container container,
            IEnumerable <KeyValuePair <Type, Func <object> > > commandConsumers,
            IEnumerable <KeyValuePair <Type, Func <object> > > eventConsumers)
        {
            var factory = new BusFactory(container.GetInstance);

            container.RegisterSingle <IBusFactory>(() => factory);

            Action <ServiceBusConfigurator> config = sbc => sbc.UseRabbitMq();

            factory.InitCommanding(commandConsumers, config);

            factory.InitEventing(eventConsumers, config);
            container.RegisterSingle <IEventBus, EventBus>();
            container.RegisterSingle <ICommandBus, CommandBus>();
            container.RegisterSingleDecorator(typeof(ICommandBus), typeof(MassTransitCommandBusDecorator));
            container.RegisterWithContext(
                context =>
            {
                if (context.ImplementationType == typeof(CommandBus))
                {
                    return(factory.ResponseQueue());
                }
                return(factory.ReadModelQueue());
            });
        }