public void StartService(MailDeliveryServiceSettings settings)
        {
            _nancyHost = new NancyHost(_bootstrapper, new HostConfiguration
            {
                UrlReservations = new UrlReservations {
                    CreateAutomatically = true
                }
            }, settings.BaseUrlsAsArray());

            _logger.Info("Starting the service");
            _nancyHost.Start();
            _logger.Info("Service is running");
        }
Пример #2
0
        protected override void ConfigureApplicationContainer(ILifetimeScope existingContainer)
        {
            base.ConfigureApplicationContainer(existingContainer);
            var settings = MailDeliveryServiceSettings.Current();

            var builder = new ContainerBuilder();

            RegisterConsumers(builder);
            RegisterLoggers(builder);
            RegisterCommandProcessor(builder);
            RegisterMessaging(builder, settings);

            builder.Update(existingContainer.ComponentRegistry);
        }
Пример #3
0
        private void RegisterMessaging(ContainerBuilder builder, MailDeliveryServiceSettings settings)
        {
            builder.Register(context =>
            {
                var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
                {
                    cfg.Host(new Uri("rabbitmq://" + settings.BrokerSettings.HostName), h =>
                    {
                        h.Username(settings.BrokerSettings.UserName);
                        h.Password(settings.BrokerSettings.Password);
                    });
                });

                return(busControl);
            })
            .SingleInstance()
            .As <IBusControl>();
        }
 public static MailDeliveryServiceSettings Current()
 {
     return(_serviceSettings ?? (_serviceSettings = ConfigurationManager.Instance.AppSettings.Map <MailDeliveryServiceSettings>()));
 }