// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHealthChecks(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddMassTransit(x => { x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg => { var host = cfg.Host(new Uri("amqp://*****:*****@rabbit:5672/"), ep => { }); cfg.ReceiveEndpoint("consumer_create_queue", ep => { ep.Consumer <CustomerConsumer>(); }); })); }); var redisConnection = "redis://redis:6379"; var redis = ConnectionMultiplexer.Connect(redisConnection); var repository = new RedisSagaRepository <TedSaga>(redis, "saga:ted"); services.AddSingleton(repository); services.AddSingleton <IHostedService, MassTransitHostedService>(); }
static async Task Main(string[] args) { var redisConnectionString = "localhost:6379"; var redis = ConnectionMultiplexer.Connect(redisConnectionString); var repository = RedisSagaRepository <OrderState> .Create(() => redis.GetDatabase()); var machine = new StateMachine(); var busControl = Bus.Factory.CreateUsingRabbitMq(cfg => { cfg.Host(new Uri("rabbitmq://localhost"), host => { host.Username("guest"); host.Password("guest"); }); cfg.ReceiveEndpoint("saga_order", e => { e.StateMachineSaga(machine, repository); }); }); await busControl.StartAsync(); Console.WriteLine("Press any key to exit"); await Task.Run(() => Console.ReadKey()); }
public LocatingAnExistingSaga() { var redis = ConnectionMultiplexer.Connect("127.0.0.1"); redis.PreserveAsyncOrder = false; _sagaRepository = new Lazy <ISagaRepository <SimpleSaga> >(() => RedisSagaRepository <SimpleSaga> .Create(() => redis.GetDatabase())); }
static void Main(string[] args) { var redisConnectionString = "localhost:6379"; var redis = ConnectionMultiplexer.Connect(redisConnectionString); var repository = new RedisSagaRepository <OrderState>(() => redis.GetDatabase()); var machine = new StateMachine(); var busControl = Bus.Factory.CreateUsingRabbitMq(cfg => { cfg.Host(new Uri("rabbitmq://localhost"), host => { host.Username("guest"); host.Password("guest"); }); cfg.ReceiveEndpoint("saga_order", e => { e.StateMachineSaga(machine, repository); }); }); busControl.Start(); }