private void ConfigureMassTransit(IServiceCollection services) { var massTransitSettingSection = _configuration.GetSection("MassTransitConfig"); var massTransitConfig = massTransitSettingSection.Get <MassTransitConfig>(); services.AddMassTransit(i => { i.AddConsumer <FulfillOrderConsumer>() .Endpoint(e => { e.Name = QueueNames.GetQueueName(nameof(IFulfillOrder)); } ); i.AddConsumer <ChangeOrderStatusConsumer>(); i.AddActivities(Assembly.GetExecutingAssembly()); var timeout = TimeSpan.FromSeconds(180); i.AddRequestClient <IReserveProducts>(timeout); i.AddRequestClient <ICancelReservation>(timeout); i.AddRequestClient <IOrderPayment>(timeout); i.AddRequestClient <ICancelPayment>(timeout); i.AddRequestClient <IDeliveryRequest>(timeout); i.SetKebabCaseEndpointNameFormatter(); i.AddSagaStateMachine <OrderStateMachine, OrderState>() .InMemoryRepository(); i.UsingRabbitMq((context, cfg) => { cfg.UseInMemoryOutbox(); cfg.ConfigureEndpoints(context); cfg.Host(massTransitConfig.Host, massTransitConfig.VirtualHost, h => { h.Username(massTransitConfig.Username); h.Password(massTransitConfig.Password); } ); }); }); services.AddMassTransitHostedService(); services.AddScoped <FulfillOrderActivity>(); }