Merge branch 'order-processflow-redesign' of https://github.com/dotnet-architecture/eShopOnContainers into order-processflow-redesign
# Conflicts: # src/Services/SagaManager/SagaManager/Program.cs
This commit is contained in:
commit
63cba2cad9
@ -165,12 +165,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
|
|
||||||
protected virtual void ConfigureEventBus(IApplicationBuilder app)
|
protected virtual void ConfigureEventBus(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
var catalogPriceHandler = app.ApplicationServices
|
|
||||||
.GetService<IIntegrationEventHandler<ProductPriceChangedIntegrationEvent>>();
|
|
||||||
|
|
||||||
var orderStartedHandler = app.ApplicationServices
|
|
||||||
.GetService<IIntegrationEventHandler<OrderStartedIntegrationEvent>>();
|
|
||||||
|
|
||||||
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
||||||
|
|
||||||
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
|
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
using BuildingBlocks.EventBus.Abstractions;
|
using BuildingBlocks.EventBus.Abstractions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using global::Catalog.API.Infrastructure.Exceptions;
|
|
||||||
using global::Catalog.API.IntegrationEvents;
|
|
||||||
using Model;
|
|
||||||
using Commands;
|
using Commands;
|
||||||
|
|
||||||
public class DecrementOrderStockCommandMsgHandler : IIntegrationEventHandler<DecrementOrderStockCommandMsg>
|
public class DecrementOrderStockCommandMsgHandler : IIntegrationEventHandler<DecrementOrderStockCommandMsg>
|
||||||
|
@ -121,10 +121,7 @@
|
|||||||
return new DefaultRabbitMQPersistentConnection(factory, logger);
|
return new DefaultRabbitMQPersistentConnection(factory, logger);
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
|
RegisterServiceBus(services);
|
||||||
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<ConfirmOrderStockCommandMsg>, ConfirmOrderStockCommandMsgHandler>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<DecrementOrderStockCommandMsg>, DecrementOrderStockCommandMsgHandler>();
|
|
||||||
|
|
||||||
var container = new ContainerBuilder();
|
var container = new ContainerBuilder();
|
||||||
container.Populate(services);
|
container.Populate(services);
|
||||||
@ -188,6 +185,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RegisterServiceBus(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
|
||||||
|
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
|
||||||
|
|
||||||
|
services.AddTransient<IIntegrationEventHandler<ConfirmOrderStockCommandMsg>,
|
||||||
|
ConfirmOrderStockCommandMsgHandler>();
|
||||||
|
services.AddTransient<IIntegrationEventHandler<DecrementOrderStockCommandMsg>,
|
||||||
|
DecrementOrderStockCommandMsgHandler>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void ConfigureEventBus(IApplicationBuilder app)
|
private void ConfigureEventBus(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
// make sure that consistency is preserved across the whole aggregate
|
// make sure that consistency is preserved across the whole aggregate
|
||||||
var address = new Address(message.Street, message.City, message.State, message.Country, message.ZipCode);
|
var address = new Address(message.Street, message.City, message.State, message.Country, message.ZipCode);
|
||||||
var order = new Order(message.UserId, address, message.CardTypeId, message.CardNumber, message.CardSecurityNumber, message.CardHolderName, message.CardExpiration);
|
var order = new Order(message.UserId, address, message.CardTypeId, message.CardNumber, message.CardSecurityNumber, message.CardHolderName, message.CardExpiration);
|
||||||
order.SetSubmitedStatus();
|
|
||||||
foreach (var item in message.OrderItems)
|
foreach (var item in message.OrderItems)
|
||||||
{
|
{
|
||||||
order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units);
|
order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units);
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent)
|
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent)
|
||||||
{
|
{
|
||||||
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
|
|
||||||
|
|
||||||
_logger.CreateLogger(nameof(OrderStatusChangedToAwaitingValidationDomainEvent))
|
_logger.CreateLogger(nameof(OrderStatusChangedToAwaitingValidationDomainEvent))
|
||||||
.LogTrace($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " +
|
.LogTrace($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " +
|
||||||
$"a status order id: {OrderStatus.AwaitingValidation.Id}");
|
$"a status order id: {OrderStatus.AwaitingValidation.Id}");
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent)
|
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent)
|
||||||
{
|
{
|
||||||
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
|
|
||||||
|
|
||||||
_logger.CreateLogger(nameof(OrderStatusChangedToPaidDomainEventHandler))
|
_logger.CreateLogger(nameof(OrderStatusChangedToPaidDomainEventHandler))
|
||||||
.LogTrace($"Order with Id: {orderStatusChangedToPaidDomainEvent.OrderId} has been successfully updated with " +
|
.LogTrace($"Order with Id: {orderStatusChangedToPaidDomainEvent.OrderId} has been successfully updated with " +
|
||||||
$"a status order id: {OrderStatus.Paid.Id}");
|
$"a status order id: {OrderStatus.Paid.Id}");
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
|
|
||||||
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent)
|
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent)
|
||||||
{
|
{
|
||||||
await _orderRepository.UnitOfWork.SaveEntitiesAsync();
|
|
||||||
|
|
||||||
_logger.CreateLogger(nameof(OrderStatusChangedToStockConfirmedDomainEventHandler))
|
_logger.CreateLogger(nameof(OrderStatusChangedToStockConfirmedDomainEventHandler))
|
||||||
.LogTrace($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " +
|
.LogTrace($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " +
|
||||||
$"a status order id: {OrderStatus.StockConfirmed.Id}");
|
$"a status order id: {OrderStatus.StockConfirmed.Id}");
|
||||||
|
@ -48,11 +48,8 @@ namespace Ordering.API.Application.Sagas
|
|||||||
var orderSaga = FindSagaById(command.OrderId);
|
var orderSaga = FindSagaById(command.OrderId);
|
||||||
CheckValidSagaId(orderSaga);
|
CheckValidSagaId(orderSaga);
|
||||||
|
|
||||||
if (orderSaga.OrderStatus != OrderStatus.Cancelled)
|
orderSaga.SetAwaitingValidationStatus();
|
||||||
{
|
await SaveChangesAsync();
|
||||||
orderSaga.SetAwaitingValidationStatus();
|
|
||||||
await SaveChangesAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -67,14 +64,9 @@ namespace Ordering.API.Application.Sagas
|
|||||||
var orderSaga = FindSagaById(command.OrderNumber);
|
var orderSaga = FindSagaById(command.OrderNumber);
|
||||||
CheckValidSagaId(orderSaga);
|
CheckValidSagaId(orderSaga);
|
||||||
|
|
||||||
// Not possible to cancel order when
|
orderSaga.SetCancelledStatus();
|
||||||
// it has already been shipped
|
result = await SaveChangesAsync();
|
||||||
if (orderSaga.GetOrderStatusId() != OrderStatus.Cancelled.Id
|
|
||||||
|| orderSaga.GetOrderStatusId() != OrderStatus.Shipped.Id)
|
|
||||||
{
|
|
||||||
orderSaga.SetCancelledStatus();
|
|
||||||
result = await SaveChangesAsync();
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,13 +82,9 @@ namespace Ordering.API.Application.Sagas
|
|||||||
var orderSaga = FindSagaById(command.OrderNumber);
|
var orderSaga = FindSagaById(command.OrderNumber);
|
||||||
CheckValidSagaId(orderSaga);
|
CheckValidSagaId(orderSaga);
|
||||||
|
|
||||||
// Only ship order when
|
orderSaga.SetShippedStatus();
|
||||||
// its status is paid
|
result = await SaveChangesAsync();
|
||||||
if (orderSaga.GetOrderStatusId() == OrderStatus.Paid.Id)
|
|
||||||
{
|
|
||||||
orderSaga.SetShippedStatus();
|
|
||||||
result = await SaveChangesAsync();
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
using global::Ordering.API.Application.IntegrationEvents.Events;
|
using global::Ordering.API.Application.IntegrationEvents.Events;
|
||||||
using global::Ordering.API.Application.Sagas;
|
using global::Ordering.API.Application.Sagas;
|
||||||
using global::Ordering.API.Infrastructure.Middlewares;
|
using global::Ordering.API.Infrastructure.Middlewares;
|
||||||
using global::Ordering.API.Application.IntegrationCommands.Commands;
|
|
||||||
using global::Ordering.API.Application.Sagas;
|
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Auth;
|
using Infrastructure.Auth;
|
||||||
using Infrastructure.AutofacModules;
|
using Infrastructure.AutofacModules;
|
||||||
@ -126,18 +124,7 @@
|
|||||||
return new DefaultRabbitMQPersistentConnection(factory, logger);
|
return new DefaultRabbitMQPersistentConnection(factory, logger);
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
|
RegisterServiceBus(services);
|
||||||
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>, OrderProcessSaga>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>,
|
|
||||||
OrderStockConfirmedIntegrationEventHandler>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<OrderStockNotConfirmedIntegrationEvent>,
|
|
||||||
OrderStockNotConfirmedIntegrationEventHandler>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>,
|
|
||||||
OrderPaymentFailedIntegrationEventHandler>();
|
|
||||||
services.AddTransient<IIntegrationEventHandler<OrderPaymentSuccededIntegrationEvent>,
|
|
||||||
OrderPaymentSuccededIntegrationEventHandler>();
|
|
||||||
services.AddOptions();
|
services.AddOptions();
|
||||||
|
|
||||||
//configure autofac
|
//configure autofac
|
||||||
@ -178,6 +165,23 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RegisterServiceBus(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
|
||||||
|
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
|
||||||
|
|
||||||
|
services.AddTransient<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>();
|
||||||
|
services.AddTransient<IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>, OrderProcessSaga>();
|
||||||
|
services.AddTransient<IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>,
|
||||||
|
OrderStockConfirmedIntegrationEventHandler>();
|
||||||
|
services.AddTransient<IIntegrationEventHandler<OrderStockNotConfirmedIntegrationEvent>,
|
||||||
|
OrderStockNotConfirmedIntegrationEventHandler>();
|
||||||
|
services.AddTransient<IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>,
|
||||||
|
OrderPaymentFailedIntegrationEventHandler>();
|
||||||
|
services.AddTransient<IIntegrationEventHandler<OrderPaymentSuccededIntegrationEvent>,
|
||||||
|
OrderPaymentSuccededIntegrationEventHandler>();
|
||||||
|
}
|
||||||
|
|
||||||
private void ConfigureEventBus(IApplicationBuilder app)
|
private void ConfigureEventBus(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
||||||
|
@ -95,14 +95,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Status Changes
|
#region Status Changes
|
||||||
public void SetSubmitedStatus()
|
|
||||||
{
|
|
||||||
_orderStatusId = OrderStatus.Submited.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAwaitingValidationStatus()
|
public void SetAwaitingValidationStatus()
|
||||||
{
|
{
|
||||||
if (_orderStatusId != OrderStatus.Submited.Id)
|
if (_orderStatusId != OrderStatus.Submited.Id &&
|
||||||
|
_orderStatusId != OrderStatus.Cancelled.Id)
|
||||||
{
|
{
|
||||||
StatusChangeException();
|
StatusChangeException();
|
||||||
}
|
}
|
||||||
@ -167,7 +164,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
{
|
{
|
||||||
if (_orderStatusId == OrderStatus.Submited.Id)
|
if (_orderStatusId == OrderStatus.Submited.Id)
|
||||||
{
|
{
|
||||||
_description = "The order was cancelled before the grace period was confirm.";
|
_description = "The order was cancelled before the grace period was confirmed.";
|
||||||
}
|
}
|
||||||
else if (_orderStatusId == OrderStatus.AwaitingValidation.Id)
|
else if (_orderStatusId == OrderStatus.AwaitingValidation.Id)
|
||||||
{
|
{
|
||||||
@ -191,11 +188,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public int GetOrderStatusId()
|
|
||||||
{
|
|
||||||
return _orderStatusId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddOrderStartedDomainEvent(string userId, int cardTypeId, string cardNumber,
|
private void AddOrderStartedDomainEvent(string userId, int cardTypeId, string cardNumber,
|
||||||
string cardSecurityNumber, string cardHolderName, DateTime cardExpiration)
|
string cardSecurityNumber, string cardHolderName, DateTime cardExpiration)
|
||||||
{
|
{
|
||||||
|
@ -2,13 +2,10 @@
|
|||||||
{
|
{
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
|
||||||
// Integration Events notes:
|
|
||||||
// An Event is “something that has happened in the past”, therefore its name has to be
|
|
||||||
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
|
||||||
public class ConfirmGracePeriodCommandMsg : IntegrationEvent
|
public class ConfirmGracePeriodCommandMsg : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int OrderId { get;}
|
public int OrderId { get;}
|
||||||
|
|
||||||
public ConfirmGracePeriodCommandMsg(int orderId) => OrderId = orderId;
|
public ConfirmGracePeriodCommandMsg(int orderId) => OrderId = orderId;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,13 +9,9 @@
|
|||||||
private readonly IEventBus _eventBus;
|
private readonly IEventBus _eventBus;
|
||||||
|
|
||||||
public SagaManagerIntegrationEventService(IEventBus eventBus)
|
public SagaManagerIntegrationEventService(IEventBus eventBus)
|
||||||
{
|
=> _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
|
||||||
_eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PublishThroughEventBus(IntegrationEvent evt)
|
|
||||||
{
|
public void PublishThroughEventBus(IntegrationEvent evt) => _eventBus.Publish(evt);
|
||||||
_eventBus.Publish(evt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,34 +1,27 @@
|
|||||||
using System.Reflection;
|
namespace SagaManager
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using SagaManager.IntegrationEvents;
|
|
||||||
|
|
||||||
namespace SagaManager
|
|
||||||
{
|
{
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Autofac;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using Services;
|
using Services;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using IntegrationEvents;
|
||||||
using Autofac;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static IConfigurationRoot Configuration { get; set; }
|
public static IConfigurationRoot Configuration { get; set; }
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args) => MainAsync().Wait();
|
||||||
{
|
|
||||||
MainAsync().Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async Task MainAsync()
|
static async Task MainAsync()
|
||||||
{
|
{
|
||||||
StartUp();
|
StartUp();
|
||||||
@ -66,8 +59,7 @@ namespace SagaManager
|
|||||||
.Configure<SagaManagerSettings>(Configuration)
|
.Configure<SagaManagerSettings>(Configuration)
|
||||||
.AddSingleton<ISagaManagerService, SagaManagerService>()
|
.AddSingleton<ISagaManagerService, SagaManagerService>()
|
||||||
.AddSingleton<ISagaManagerIntegrationEventService, SagaManagerIntegrationEventService>()
|
.AddSingleton<ISagaManagerIntegrationEventService, SagaManagerIntegrationEventService>()
|
||||||
.AddSingleton<IEventBus, EventBusRabbitMQ>()
|
|
||||||
.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>()
|
|
||||||
.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
||||||
{
|
{
|
||||||
var settings = sp.GetRequiredService<IOptions<SagaManagerSettings>>().Value;
|
var settings = sp.GetRequiredService<IOptions<SagaManagerSettings>>().Value;
|
||||||
@ -78,8 +70,7 @@ namespace SagaManager
|
|||||||
};
|
};
|
||||||
|
|
||||||
return new DefaultRabbitMQPersistentConnection(factory, logger);
|
return new DefaultRabbitMQPersistentConnection(factory, logger);
|
||||||
})
|
});
|
||||||
.AddSingleton<IEventBus, EventBusRabbitMQ>();
|
|
||||||
|
|
||||||
RegisterServiceBus(services);
|
RegisterServiceBus(services);
|
||||||
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
using System;
|
namespace SagaManager.Services
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace SagaManager.Services
|
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using IntegrationEvents;
|
using IntegrationEvents;
|
||||||
using IntegrationEvents.Events;
|
using IntegrationEvents.Events;
|
||||||
@ -32,7 +29,9 @@ namespace SagaManager.Services
|
|||||||
|
|
||||||
foreach (var orderId in orderIds)
|
foreach (var orderId in orderIds)
|
||||||
{
|
{
|
||||||
Publish(orderId);
|
var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId);
|
||||||
|
|
||||||
|
_sagaManagerIntegrationEventService.PublishThroughEventBus(confirmGracePeriodEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +59,5 @@ namespace SagaManager.Services
|
|||||||
|
|
||||||
return orderIds;
|
return orderIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Publish(int orderId)
|
|
||||||
{
|
|
||||||
var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId);
|
|
||||||
|
|
||||||
// Publish through the Event Bus
|
|
||||||
_sagaManagerIntegrationEventService.PublishThroughEventBus(confirmGracePeriodEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user