static void Main(string[] args) { Console.WriteLine("Starting application..."); // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "BeursKracht", "", ""); // start event-handler EventHandler eventHandler = new EventHandler(messageHandler); eventHandler.Start(); if (_env == "Development") { Console.WriteLine("ExchangeService EventHandler started. Press any key to stop..."); Console.ReadKey(true); eventHandler.Stop(); } else { while (true) { Thread.Sleep(10000); } } }
static void Main(string[] args) { //get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); var host = rabbitMQConfigSection["Host"]; var userName = rabbitMQConfigSection["UserName"]; var password = rabbitMQConfigSection["Password"]; // start Email manager var messageHandler = new RabbitMQMessageHandler(host, userName, password, "Email", "Auditlog", ""); var manager = new EmailManager(messageHandler); manager.Start(); if (Env == "Development") { Console.WriteLine("Email service started. Press any key to stop..."); Console.ReadKey(true); manager.Stop(); } else { Console.WriteLine("Email service started."); while (true) { Thread.Sleep(10000); } } }
static void Main(string[] args) { // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; var auditlogConfigSection = Config.GetSection("Auditlog"); string logPath = auditlogConfigSection["path"]; // start auditlog manager RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Auditlog", ""); AuditLogManager manager = new AuditLogManager(messageHandler, logPath); manager.Start(); if (_env == "Development") { Console.WriteLine("Auditlog service started. Press any key to stop..."); Console.ReadKey(true); manager.Stop(); } else { Log.Information("AuditLog service started."); while (true) { Thread.Sleep(10000); } } }
private static void Startup(/*[FromServices] UserManager<ApplicationUser> _userManager*/) { // setup RabbitMQ var configSection = Config.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; string exchange = configSection["Exchange"]; string connName = configSection["ConnectionName"]; // setup messagehandler RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, exchange, connName, "asset_created.marketing", "asset_created.#"); // subscribe/listen to queue RabbitMQMessageHandler messageHandler2 = new RabbitMQMessageHandler(host, userName, password, exchange, connName, "lease_finalized.marketing", "lease_finalized.#"); // subscribe/listen to queue // setup DBContext var sqlConnectionString = Config.GetConnectionString("AppDbConnection2"); var dbContextOptions = new DbContextOptionsBuilder <AppMarketingDbDataContext>() .UseSqlServer(sqlConnectionString) .Options; var dbContext = new AppMarketingDbDataContext(dbContextOptions); //var mongoConnectionString = Config.GetConnectionString("MongoDbConnection"); //var mongoClient = new MongoClient(mongoConnectionString); //var mongoDb = mongoClient.GetDatabase("MessageDb"); //Policy // .Handle<Exception>() // .WaitAndRetry(5, r => TimeSpan.FromSeconds(5), (ex, ts) => { Log.Error("Error connecting to DB. Retrying in 5 sec."); }) // .Execute(() => DBInitializer.Initialize(dbContext)); // start event-handler EventHandlers.EventHandler eventHandler = new EventHandlers.EventHandler(messageHandler, dbContext); eventHandler.Start(); EventHandlers.EventHandler eventHandler2 = new EventHandlers.EventHandler(messageHandler2, dbContext); eventHandler2.Start(); //if (_env == "Development") //{ // Log.Information("WorkshopManagement Eventhandler started."); // Console.WriteLine("Press any key to stop..."); // Console.ReadKey(true); // eventHandler.Stop(); //} //else //{ // Log.Information("WorkshopManagement Eventhandler started."); // while (true) // { // Thread.Sleep(10000); // } //} }
private static void Startup(/*[FromServices] UserManager<ApplicationUser> _userManager*/) { // setup RabbitMQ var configSection = Config.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; string exchange = configSection["Exchange"]; // Exchagne2: listening exchange string connName = configSection["ConnectionName"]; // setup messagehandler RabbitMQMessageHandler messageHandlerMarketing = new RabbitMQMessageHandler(host, userName, password, exchange, connName, "app_approved", "app_approved.#"); // "real", ""); listening queue: marketing.lease, RabbitMQMessageHandler messageHandlerAsset = new RabbitMQMessageHandler(host, userName, password, exchange, connName, "asset_created.lease", "asset_created.#"); //setup DBContext // var sqlConnectionString = Config.GetConnectionString("AppDbConnection"); var dbContextOptions = new DbContextOptionsBuilder <AppLeaseManagementDbContext>() .UseSqlServer(sqlConnectionString) .Options; var dbContext = new AppLeaseManagementDbContext(dbContextOptions); //Policy // .Handle<Exception>() // .WaitAndRetry(5, r => TimeSpan.FromSeconds(5), (ex, ts) => { Log.Error("Error connecting to DB. Retrying in 5 sec."); }) // .Execute(() => DBInitializer.Initialize(dbContext)); // start event-handler // EventHandlers.EventHandler eventHandlerMarketing = new EventHandlers.EventHandler(messageHandlerMarketing, dbContext); // Subscribe/Handle message publshied by Marketing Service eventHandlerMarketing.Start(); EventHandlers.EventHandler eventHandlerAsset = new EventHandlers.EventHandler(messageHandlerAsset, dbContext); // Subscribe/Handle message publshied by Asset Service eventHandlerAsset.Start(); //if (_env == "Development") //{ // Log.Information("WorkshopManagement Eventhandler started."); // Console.WriteLine("Press any key to stop..."); // Console.ReadKey(true); // eventHandler.Stop(); //} //else //{ // Log.Information("WorkshopManagement Eventhandler started."); // while (true) // { // Thread.Sleep(10000); // } //} }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("WorkshopManagementEventHandlerType", context => new WorkshopManagementEventHandler(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(WorkshopManagementEventHandler).Name); // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; // setup messagehandler RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "WorkshopManagement", ""); // setup DBContext var sqlConnectionString = Config.GetConnectionString("WorkshopManagementCN"); var dbContextOptions = new DbContextOptionsBuilder <WorkshopManagementDBContext>() .UseSqlServer(sqlConnectionString) .Options; var dbContext = new WorkshopManagementDBContext(dbContextOptions); Policy .Handle <Exception>() .WaitAndRetry(5, r => TimeSpan.FromSeconds(5), (ex, ts) => { Console.WriteLine("Error connecting to DB. Retrying in 5 sec."); }) .Execute(() => DBInitializer.Initialize(dbContext)); // start event-handler EventHandler eventHandler = new EventHandler(messageHandler, dbContext); eventHandler.Start(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
private static void Startup() { // setup RabbitMQ var configSection = Config.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; string exchange = configSection["Exchange"]; string connName = configSection["ConnectionName"]; var mailConfigSection = Config.GetSection("EmailSettings"); string mailHost = mailConfigSection["MailServer"]; int mailPort = Convert.ToInt32(mailConfigSection["MailPort"]); string mailUserName = mailConfigSection["Sender"]; string mailSenderName = mailConfigSection["SenderName"]; string mailPassword = mailConfigSection["Password"]; //ISMTPMailSender smtpMailServer = new SMTPMailSender(mailHost, mailPort, mailUserName, mailPassword, mailSenderName); // original var smsConfiguration = Config.GetSection("SmsSettings"); string accountSid = smsConfiguration["AccountSID"]; string authCode = smsConfiguration["AuthToken"]; EmailSettings settings = new EmailSettings(mailHost, mailPort, mailSenderName, mailUserName, mailPassword); IEmailSender smtpMailServer = new EmailSender(settings); SmsSettings smsSettings = new SmsSettings(accountSid, authCode); ISmsSender smsSender = new TextSender(smsSettings); //ITwilioRestClient smsSender = new SmsSender(); //var emailSender = new EmailSender(); //var emailSettings = new EmailSettings(); // setup messagehandler RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, exchange, connName, "notification", "notification.#"); // ABOVE: subscribe/listen to queue - queue name to be updated //IEmailSender emailSender = null; EventHandlers.EventHandler eventHandler = new EventHandlers.EventHandler(messageHandler, smtpMailServer, smsSender); //, dbContext); //EventHandler eventHandler = new EventHandler(messageHandler, smtpMailServer); //EmailNotificationEventHandler eventHandler = new EmailNotificationEventHandler(messageHandler, smtpMailServer); // original eventHandler.Start(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, OrderDbInitializer dbInit) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc(); app.UseDefaultFiles(); app.UseStaticFiles(); SetupAutoMapper(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "LogisticsManagement API - v1"); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // setup messagehandler var configSection = Configuration.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Ball.com", "OrderAPI", ""); // start event-handler var eventHandler = new EventHandler.EventHandler(messageHandler, Configuration.GetConnectionString("OrderManagementCN")); eventHandler.Start(); Policy .Handle <Exception>() .WaitAndRetry(10, r => TimeSpan.FromSeconds(5)) .Execute(() => { dbInit.Seed().Wait(); }); }
private static void Startup() { // setup RabbitMQ var configSection = Config.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; // setup messagehandler RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "WorkshopManagement", ""); // setup DBContext var sqlConnectionString = Config.GetConnectionString("WorkshopManagementCN"); var dbContextOptions = new DbContextOptionsBuilder <WorkshopManagementDBContext>() .UseSqlServer(sqlConnectionString) .Options; var dbContext = new WorkshopManagementDBContext(dbContextOptions); Policy .Handle <Exception>() .WaitAndRetry(5, r => TimeSpan.FromSeconds(5), (ex, ts) => { Log.Error("Error connecting to DB. Retrying in 5 sec."); }) .Execute(() => DBInitializer.Initialize(dbContext)); // start event-handler EventHandler eventHandler = new EventHandler(messageHandler, dbContext); eventHandler.Start(); if (_env == "Development") { Log.Information("WorkshopManagement Eventhandler started."); Console.WriteLine("Press any key to stop..."); Console.ReadKey(true); eventHandler.Stop(); } else { Log.Information("WorkshopManagement Eventhandler started."); while (true) { Thread.Sleep(10000); } } }
// private void onShutdown (IBasicConsumer sender, // BasicDeliverEventArgs args) { // Debug.Log ("onShutdown"); // } public void subscribe(string eventType, RabbitMQMessageHandler handler) { switch (eventType) { case EventType.Speech: this.eventHandlers[eventType] = handler; break; case EventType.Hotword: this.eventHandlers[eventType] = handler; break; case EventType.MidAirTokens: this.eventHandlers[eventType] = handler; break; default: break; } }
static void Main(string[] args) { // get configuration var rmqConfigSection = Config.GetSection("RabbitMQ"); string rmqHost = rmqConfigSection["Host"]; string rmqUserName = rmqConfigSection["UserName"]; string rmqPassword = rmqConfigSection["Password"]; var mailConfigSection = Config.GetSection("Email"); string mailHost = mailConfigSection["Host"]; int mailPort = Convert.ToInt32(mailConfigSection["Port"]); string mailUserName = mailConfigSection["User"]; string mailPassword = mailConfigSection["Pwd"]; var sqlConnectionString = Config.GetConnectionString("NotificationServiceCN"); // start notification service RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(rmqHost, rmqUserName, rmqPassword, "Pitstop", "Notifications", ""); INotificationRepository repo = new SqlServerNotificationRepository(sqlConnectionString); IEmailNotifier emailNotifier = new SMTPEmailNotifier(mailHost, mailPort, mailUserName, mailPassword); NotificationManager manager = new NotificationManager(messageHandler, repo, emailNotifier); manager.Start(); if (_env == "Development") { Log.Information("Notification service started."); Console.WriteLine("Press any key to stop..."); Console.ReadKey(true); manager.Stop(); } else { Log.Information("Notification service started."); while (true) { Thread.Sleep(10000); } } }
static void Main(string[] args) { // get configuration var configSection = Config.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; var sqlConnectionString = Config.GetConnectionString("InvoiceServiceCN"); var mailConfigSection = Config.GetSection("Email"); string mailHost = mailConfigSection["Host"]; int mailPort = Convert.ToInt32(mailConfigSection["Port"]); string mailUserName = mailConfigSection["User"]; string mailPassword = mailConfigSection["Pwd"]; // start invoice manager RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Invoicing", ""); IInvoiceRepository repo = new SqlServerInvoiceRepository(sqlConnectionString); IEmailCommunicator emailCommunicator = new SMTPEmailCommunicator(mailHost, mailPort, mailUserName, mailPassword); InvoiceManager manager = new InvoiceManager(messageHandler, repo, emailCommunicator); manager.Start(); if (_env == "Development") { Log.Information("Invoice service started."); Console.WriteLine("Press any key to stop..."); Console.ReadKey(true); manager.Stop(); } else { Log.Information("Invoice service started."); while (true) { Thread.Sleep(10000); } } }
static void Main(string[] args) { try { ServiceRuntime.RegisterServiceAsync("InvoiceServiceType", context => new inv.InvoiceService(context)).GetAwaiter().GetResult(); inv.ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(inv.InvoiceService).Name); // get configuration var configSection = Config.GetSection("RabbitMQ"); string host = configSection["Host"]; string userName = configSection["UserName"]; string password = configSection["Password"]; var sqlConnectionString = Config.GetConnectionString("InvoiceServiceCN"); var mailConfigSection = Config.GetSection("Email"); string mailHost = mailConfigSection["Host"]; int mailPort = Convert.ToInt32(mailConfigSection["Port"]); string mailUserName = mailConfigSection["User"]; string mailPassword = mailConfigSection["Pwd"]; // start invoice manager var messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Invoicing", ""); IInvoiceRepository repo = new SqlServerInvoiceRepository(sqlConnectionString); IEmailCommunicator emailCommunicator = new SMTPEmailCommunicator(mailHost, mailPort, mailUserName, mailPassword); var manager = new InvoiceManager(messageHandler, repo, emailCommunicator); manager.Start(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { inv.ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("AuditlogServiceType", context => new AuditlogService(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(AuditlogService).Name); // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; var auditlogConfigSection = Config.GetSection("Auditlog"); string logPath = auditlogConfigSection["path"]; // start auditlog manager RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Auditlog", ""); AuditLogManager manager = new AuditLogManager(messageHandler, logPath); manager.Start(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
private static void Main(string[] args) { // get configuration var configSection = Config.GetSection("RabbitMQ"); var host = configSection["Host"]; var userName = configSection["UserName"]; var password = configSection["Password"]; var sqlConnectionString = Config.GetConnectionString("ShippingCN"); var services = new ServiceCollection(); services.AddDbContext <ShippingDbContext>(options => options.UseSqlServer(sqlConnectionString)); //...add any other services needed //services.AddTransient<IProductRepository, ProductRepository>(); //services.AddTransient<ICustomerRepository, CustomerRepository>(); //services.AddTransient<IOrderRepository, EFOrderRepository>(); //services.AddTransient<ILogisticsRepository, LogisticsRepository>(); //services.AddTransient<IPackageRepository, EFPackageRepository>(); services.AddTransient <ILogisticsService, LogisticsService>(); services.AddTransient <IMessageHandlerCallback, EventHandler>(); services.AddTransient <IMessagePublisher>((sp) => new RabbitMQMessagePublisher(host, userName, password, "Ball.com")); services.AddSingleton <IMessageHandler>((sp) => new RabbitMQMessageHandler(host, userName, password, "Ball.com", "Shipping", "")); // then build provider var serviceProvider = services.BuildServiceProvider(); //var messageHandlerCallback = serviceProvider.GetService<IMessageHandlerCallback>(); RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Ball.com", "OrderAPI", ""); var dbContext = serviceProvider.GetService <ShippingDbContext>(); var messagePublisher = serviceProvider.GetService <IMessagePublisher>(); var logisticsService = serviceProvider.GetService <ILogisticsService>(); SetupAutoMapper(); //Policy // .Handle<Exception>() // .WaitAndRetry(5, r => TimeSpan.FromSeconds(5), // (ex, ts) => { Console.WriteLine("Error connecting to DB. Retrying in 5 sec."); }) // .Execute(() => dbContext.Database.Migrate()); // start event-handler var eventHandler = new EventHandler(messagePublisher, messageHandler, logisticsService, Config.GetConnectionString("ShippingCN")); eventHandler.Start(); if (Env == "Development") { Console.WriteLine("Shipping service started. Press any key to stop..."); Console.ReadKey(true); messageHandler.Stop(); } else { Console.WriteLine("Shipping service started."); while (true) { Thread.Sleep(10000); } } }
private static void Startup(/*[FromServices] UserManager<ApplicationUser> _userManager*/) { // setup RabbitMQ var mgConfigSection = Config.GetSection("RabbitMQ"); string host = mgConfigSection["Host"]; string userName = mgConfigSection["UserName"]; string password = mgConfigSection["Password"]; string exchange = mgConfigSection["Exchange2"]; // Exchagne2: listening exchange // setup messagehandler RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, exchange, "", "marketing", ""); // "real", ""); listening queue: marketing, publishing queue: asset // setup Email var emailConfigSection = Config.GetSection("Email"); string smtpHost = emailConfigSection["Host"]; string accountUserName = emailConfigSection["User"]; string accountPassword = emailConfigSection["Pwd"]; // setup SMS var smsConfigSection = Config.GetSection("SMS"); //string smsHost = smsConfigSection["Host"]; string accountName = smsConfigSection["Account"]; string accountToken = smsConfigSection["Token"]; // setup DBContext - MongoDB - TO DO *********************************************************************** // //var sqlConnectionString = Config.GetConnectionString("AppDbConnection3"); //var dbContextOptions = new DbContextOptionsBuilder<AppDataBaseContext>() // .UseSqlServer(sqlConnectionString) // .Options; //var dbContext = new AppDataBaseContext(dbContextOptions); //Policy // .Handle<Exception>() // .WaitAndRetry(5, r => TimeSpan.FromSeconds(5), (ex, ts) => { Log.Error("Error connecting to DB. Retrying in 5 sec."); }) // .Execute(() => DBInitializer.Initialize(dbContext)); // start event-handler - TO DO *********************************************************************** // //EventHandlers.EventHandler eventHandler = new EventHandlers.EventHandler(messageHandler, dbContext); //eventHandler.Start(); //if (_env == "Development") //{ // Log.Information("WorkshopManagement Eventhandler started."); // Console.WriteLine("Press any key to stop..."); // Console.ReadKey(true); // eventHandler.Stop(); //} //else //{ // Log.Information("WorkshopManagement Eventhandler started."); // while (true) // { // Thread.Sleep(10000); // } //} }
public MaintenanceManager(RabbitMQMessageHandler messageHandler, MaintenanceService maintenanceService) { _messageHandler = messageHandler; _maintenanceService = maintenanceService; }
public CarManager(RabbitMQMessageHandler messageHandler, CarManagementService carService) { _messageHandler = messageHandler; _carService = carService; }
public AdvertisementManager(RabbitMQMessageHandler messageHandler, AdvertisementService advertisementService) { _messageHandler = messageHandler; _advertisementService = advertisementService; }