public static IBus CreateBus(string connectionStringKey) { var appSettings = new AppSettings(); var connectionString = appSettings.ConnectionStrings.Get(connectionStringKey, () => DefaultConnection); var subscriptionPrefix = appSettings.RabbitMQ.SubscriptionPrefix; try { Log.InfoFormat("Connecting to RabbitMQ via {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); var logger = new RabbitMQLogger(); var bus = RabbitHutch.CreateBus(connectionString, x => x.Register<IEasyNetQLogger>(p => logger)); Log.DebugFormat("Connected to RabbitMQ on {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); return bus; } catch (Exception e) { Log.ErrorFormat("Failed to create a bus for RabbitMQ with connectionstring: {0}", connectionString); Log.ErrorFormat("The failure was {0}", e.Message); throw; } }
public void Install(IWindsorContainer container, IConfigurationStore store) { log.InfoFormat("Installing SQL Server connection"); var appSettings = new AppSettings(); container.Register(Component.For(typeof(IRepository<>)).ImplementedBy(typeof(Repository<>)).LifestyleTransient()); }
public IBus CreateConsumerBus(string connectionStringKey, ConsumerRegistration consumers) { var appSettings = new AppSettings(); var connectionString = appSettings.ConnectionStrings.Get(connectionStringKey, () => DefaultConnection); var subscriptionPrefix = appSettings.RabbitMQ.SubscriptionPrefix; try { var bus = CreateBus(connectionStringKey, null); var dispatcher = new NoMagicAutoDispatcher(consumers); var autoSubscriber = new AutoSubscriber(bus, subscriptionPrefix) { AutoSubscriberMessageDispatcher = dispatcher }; var consumerAssemblies = consumers.GetAssemblies(); autoSubscriber.Subscribe(consumerAssemblies); Log.DebugFormat("Connected to RabbitMQ on {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); return bus; } catch (Exception e) { Log.ErrorFormat("Failed to create a bus for RabbitMQ with connectionstring: {0}", connectionString); Log.ErrorFormat("The failure was {0}", e.Message); throw; } }
public void Install(IWindsorContainer container, IConfigurationStore store) { this.Info(() => "Attempting to install RedisInstaller"); var appSettings = new AppSettings(); var options = ConfigurationOptions.Parse(appSettings.UserManagementApi.RedisServers); options.AbortOnConnectFail = false; container.Register(Component.For<ConnectionMultiplexer>().Instance(ConnectionMultiplexer.Connect(options))); this.Info(() => "Successfully installed RedisInstaller"); }
public static void Main(string[] args) { var appSettings = new AppSettings(); HostFactory.Run(x => { x.Service<IReportingService>(s => { s.ConstructUsing(name => new ReportingService()); s.WhenStarted(rs => rs.Start()); s.WhenStopped(rs => rs.Stop()); }); x.RunAsLocalSystem(); x.SetDescription(appSettings.Service.Description); x.SetDisplayName(appSettings.Service.DisplayName); x.SetServiceName(appSettings.Service.Name); }); }
static void Main(string[] args) { var appSettings = new AppSettings(); HostFactory.Run(x => { x.RunAsPrompt(); x.Service<IKeepAliveService>(s => { s.ConstructUsing(name => new KeepAliveService()); s.WhenStarted(tc => tc.Start()); s.WhenStopped(tc => tc.Stop()); }); x.RunAsPrompt(); x.SetDescription(appSettings.Service.Description); x.SetDisplayName(appSettings.Service.DisplayName); x.SetServiceName(appSettings.Service.Name); }); }
public IBus CreateBus(string connectionStringKey, IWindsorContainer container) { var appSettings = new AppSettings(); var connectionString = appSettings.ConnectionStrings.Get(connectionStringKey, () => DefaultConnection); var subscriptionPrefix = appSettings.RabbitMQ.SubscriptionPrefix; try { Log.InfoFormat("Connecting to RabbitMQ via {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); var logger = new RabbitMQLogger(); var bus = RabbitHutch.CreateBus(connectionString, x => x.Register<IEasyNetQLogger>(p => logger)); var autoSubscriber = new AutoSubscriber(bus, subscriptionPrefix) { AutoSubscriberMessageDispatcher = new WindsorMessageDispatcher(container) }; var registration = new ConsumerRegistration(); var assemblies = registration.GetAssemblies(container); autoSubscriber.Subscribe(assemblies.ToArray()); autoSubscriber.SubscribeAsync(assemblies.ToArray()); Log.DebugFormat("Connected to RabbitMQ on {0} and using subscription prefix {1}", connectionString, subscriptionPrefix); return bus; } catch (Exception e) { Log.ErrorFormat("Failed to create a bus for RabbitMQ with connectionstring: {0}", connectionString); Log.ErrorFormat("The failure was {0}", e.Message); throw; } }
public static IAdvancedBus CreateAdvancedBus(IDefineQueue queue) { var appSettings = new AppSettings(); var connectionString = appSettings.ConnectionStrings.Get(queue.ConnectionStringKey, () => DefaultConnection); IConventions conventions = new Conventions(new TypeNameSerializer()) { //ExchangeNamingConvention = type => queue.ExchangeName, //QueueNamingConvention = (type, information) => queue.QueueName, TopicNamingConvention = type => queue.ExchangeType, // type.Name, ErrorExchangeNamingConvention = information => queue.ErrorExchangeName, ErrorQueueNamingConvention = () => queue.ErrorQueueName }; var bus = RabbitHutch.CreateBus(connectionString, x => { x.Register(provider => conventions); x.Register<IEasyNetQLogger, RabbitMQLogger>(); }).Advanced; return bus; }