Esempio n. 1
0
        /// <summary>
        /// Use MSMQ as bus for messaging.
        /// </summary>
        /// <param name="bootstrapper">Bootstrapper instance.</param>
        /// <returns>Bootstrapper instance.</returns>
        public static Bootstrapper UseMSMQClientBus(this Bootstrapper bootstrapper, MSMQClientBusConfiguration configuration)
        {
            var service = MSMQBootstrappService.Instance;

            service.BootstrappAction = (ctx) =>
            {
                if (ctx.IsServiceRegistered(BootstrapperServiceType.IoC))
                {
                    bootstrapper.AddIoCRegistrations(
                        new TypeRegistration(typeof(MSMQClientBus), typeof(IDomainEventBus)),
                        new InstanceTypeRegistration(configuration ?? MSMQClientBusConfiguration.Default,
                                                     typeof(MSMQClientBusConfiguration)));
                }
            };

            if (!bootstrapper.RegisteredServices.Any(s => s == service))
            {
                bootstrapper.AddService(service);
            }

            return(bootstrapper);
        }
Esempio n. 2
0
        public static Bootstrapper UseRabbitMQClientBus(this Bootstrapper bootstrapper,
                                                        RabbitPublisherBusConfiguration?configuration = null)
        {
            var service = new RabbitMQBootstrappService(ctx =>
            {
                RabbitMQContext.Configuration = configuration ?? RabbitPublisherBusConfiguration.Default;
                if (ctx.IsServiceRegistered(BootstrapperServiceType.IoC))
                {
                    bootstrapper.AddIoCRegistrations(
                        new TypeRegistration(typeof(RabbitMQEventBus), typeof(IDomainEventBus)),
                        new InstanceTypeRegistration(configuration ?? RabbitPublisherBusConfiguration.Default,
                                                     typeof(RabbitPublisherBusConfiguration), typeof(AbstractBaseConfiguration)));
                    RegisterRabbitClientWithinContainer(bootstrapper);
                }
            });

            if (!bootstrapper.RegisteredServices.Any(s => s == service))
            {
                bootstrapper.AddService(service);
            }
            return(bootstrapper);
        }
Esempio n. 3
0
        /// <summary>
        /// Use RabbitMQ Server to listen from events on a specific rabbitMQ instance.
        /// </summary>
        /// <param name="bootstrapper">Bootstrapper instance.</param>
        /// <param name="configuration">Configuration to use RabbitMQ</param>
        /// <returns>Bootstrapper instance</returns>
        public static Bootstrapper UseRabbitMQServer(this Bootstrapper bootstrapper, RabbitMQServerConfiguration configuration = null)
        {
            var service = RabbitMQBootstrappService.Instance;

            service.BootstrappAction += (ctx) =>
            {
                RabbitMQClient.s_configuration = configuration ?? RabbitMQServerConfiguration.Default;
                if (ctx.IsServiceRegistered(BootstrapperServiceType.IoC))
                {
                    bootstrapper.AddIoCRegistrations(
                        new TypeRegistration(typeof(RabbitMQServer), typeof(RabbitMQServer)),
                        new InstanceTypeRegistration(configuration ?? RabbitMQServerConfiguration.Default,
                                                     typeof(RabbitMQServerConfiguration), typeof(AbstractBaseConfiguration)));
                    RegisterRabbitClientWithinContainer(bootstrapper);
                }
            };

            if (!bootstrapper.RegisteredServices.Any(s => s == service))
            {
                bootstrapper.AddService(service);
            }
            return(bootstrapper);
        }