Beispiel #1
0
        public static IHostBuilder CreateHostBuilder(string[] args)
        {
            return(Host.CreateDefaultBuilder(args).ConfigureAppConfiguration((hostingContext, config) =>
            {
                config.AddJsonFile("appsettings.json", true, true);
                config.AddEnvironmentVariables();

                if (args != null)
                {
                    config.AddCommandLine(args);
                }
            })
                   .ConfigureServices((hostContext, services) =>
            {
                services.AddOptions();

                var massTransitSettings = hostContext.Configuration.GetSection("MassTransitSettings")
                                          .Get <MassTransitSettings>();
                services.AddSingleton(massTransitSettings);

                var orderSaga = new OrderSagaState();
                var repo = new InMemorySagaRepository <OrderSagaModel>();

                var bus = BusConfigurator.Instance
                          .ConfigureBus(massTransitSettings, (cfg) =>
                {
                    cfg.ReceiveEndpoint(BaseConstants.SAGAQUEUENAME, e =>
                    {
                        e.StateMachineSaga(orderSaga, repo);
                    });
                });

                bus.StartAsync();

                Console.WriteLine("Order saga started..");
                Console.ReadLine();
            }));
        }
 public OrderReceivedEvent(OrderSagaState orderSagaState)
 {
     _orderSagaState = orderSagaState;
 }