Cross-platform .NET sample microservices and container based application that runs on Linux Windows and macOS. Powered by .NET 7, Docker Containers and Azure Kubernetes Services. Supports Visual Studio, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor. Moved to https://github.com/dotnet/eShop.
Now
builder.Services.AddTransient<ProductPriceChangedIntegrationEventHandler>();builder.Services.AddTransient<OrderStatusChangedToShippedIntegrationEventHandler>();builder.Services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>();
var eventBus = app.Services.GetRequiredService<IEventBus>();eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();eventBus.Subscribe<OrderStatusChangedToShippedIntegrationEvent, OrderStatusChangedToShippedIntegrationEventHandler>();eventBus.Subscribe<OrderStatusChangedToPaidIntegrationEvent, OrderStatusChangedToPaidIntegrationEventHandler>();
After
builder.Services.AddIntegrationEventHandlers(Assembly.GetExecutingAssembly());
Now
builder.Services.AddTransient<ProductPriceChangedIntegrationEventHandler>();
builder.Services.AddTransient<OrderStatusChangedToShippedIntegrationEventHandler>();
builder.Services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>();
var eventBus = app.Services.GetRequiredService<IEventBus>();
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
eventBus.Subscribe<OrderStatusChangedToShippedIntegrationEvent, OrderStatusChangedToShippedIntegrationEventHandler>();
eventBus.Subscribe<OrderStatusChangedToPaidIntegrationEvent, OrderStatusChangedToPaidIntegrationEventHandler>();
After
builder.Services.AddIntegrationEventHandlers(Assembly.GetExecutingAssembly());
app.SubscribeIntegrationEventHandlers(Assembly.GetExecutingAssembly());
I have already implemented and tested this functionality, which works fine and removes unnecessary lines of code from the startup.