Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            var machine    = new UnderwritingStateMachine();
            var repository = new InMemorySagaRepository <UnderwritingState>();

            app.ApplicationServices.GetService <BusManager>().Start(ep =>
            {
                ep.StateMachineSaga <UnderwritingState>(machine, repository);
            }, "underwriting-state-saga");
        }
        public void Start()
        {
            var machine    = new UnderwritingStateMachine();
            var repository = new InMemorySagaRepository <UnderwritingState>();

            _bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
            {
                var host = sbc.Host(new Uri("rabbitmq://abi-rabbit"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                sbc.UseInMemoryScheduler();

                sbc.ReceiveEndpoint(host, "underwriting-state-sag", ep =>
                {
                    ep.PrefetchCount = 8;
                    ep.StateMachineSaga <UnderwritingState>(machine, repository);
                });
            });

            _bus.Start();
        }