Skip to content

Commit 5a374e9

Browse files
Refactoring Integration Events so they cannot be confused with Domain Events
1 parent b9c1778 commit 5a374e9

7 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedEventHandler.cs renamed to src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling
88
{
9-
public class ProductPriceChangedEventHandler : IIntegrationEventHandler<ProductPriceChangedEvent>
9+
public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandler<ProductPriceChangedIntegrationEvent>
1010
{
1111
private readonly IBasketRepository _repository;
12-
public ProductPriceChangedEventHandler(IBasketRepository repository)
12+
public ProductPriceChangedIntegrationEventHandler(IBasketRepository repository)
1313
{
1414
_repository = repository;
1515
}
1616

17-
public async Task Handle(ProductPriceChangedEvent @event)
17+
public async Task Handle(ProductPriceChangedIntegrationEvent @event)
1818
{
1919
var userIds = await _repository.GetUsers();
2020
foreach (var id in userIds)

src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedEvent.cs renamed to src/Services/Basket/Basket.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even
88
// Integration Events notes:
99
// An Event is “something that has happened in the past”, therefore its name has to be
1010
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
11-
public class ProductPriceChangedEvent : IntegrationEvent
11+
public class ProductPriceChangedIntegrationEvent : IntegrationEvent
1212
{
1313
public int ProductId { get; private set; }
1414

1515
public decimal NewPrice { get; private set; }
1616

1717
public decimal OldPrice { get; private set; }
1818

19-
public ProductPriceChangedEvent(int productId, decimal newPrice, decimal oldPrice)
19+
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
2020
{
2121
ProductId = productId;
2222
NewPrice = newPrice;

src/Services/Basket/Basket.API/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ public void ConfigureServices(IServiceCollection services)
7676
});
7777

7878
services.AddTransient<IBasketRepository, RedisBasketRepository>();
79-
services.AddTransient<IIntegrationEventHandler<ProductPriceChangedEvent>, ProductPriceChangedEventHandler>();
79+
services.AddTransient<IIntegrationEventHandler<ProductPriceChangedIntegrationEvent>, ProductPriceChangedIntegrationEventHandler>();
8080

8181
var serviceProvider = services.BuildServiceProvider();
8282
var configuration = serviceProvider.GetRequiredService<IOptionsSnapshot<BasketSettings>>().Value;
8383
var eventBus = new EventBusRabbitMQ(configuration.EventBusConnection);
8484
services.AddSingleton<IEventBus>(eventBus);
8585

8686

87-
var catalogPriceHandler = serviceProvider.GetService<IIntegrationEventHandler<ProductPriceChangedEvent>>();
88-
eventBus.Subscribe<ProductPriceChangedEvent>(catalogPriceHandler);
87+
var catalogPriceHandler = serviceProvider.GetService<IIntegrationEventHandler<ProductPriceChangedIntegrationEvent>>();
88+
eventBus.Subscribe<ProductPriceChangedIntegrationEvent>(catalogPriceHandler);
8989

9090
}
9191

src/Services/Catalog/Catalog.API/Catalog.API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
2323
</Content>
2424
<Compile Include="IntegrationEvents\EventHandling\AnyFutureIntegrationEventHandler.cs.txt" />
25-
<Compile Include="IntegrationEvents\Events\ProductPriceChangedEvent.cs.txt" />
25+
<Compile Include="IntegrationEvents\Events\ProductPriceChangedIntegrationEvent.cs.txt" />
2626
<Content Update="web.config;">
2727
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
2828
</Content>

src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public async Task<IActionResult> Post([FromBody]CatalogItem value)
146146
item.Price = value.Price;
147147
_context.CatalogItems.Update(item);
148148

149-
var @event = new ProductPriceChangedEvent(item.Id, item.Price, oldPrice);
149+
var @event = new ProductPriceChangedIntegrationEvent(item.Id, item.Price, oldPrice);
150150
var eventLogEntry = new IntegrationEventLogEntry(@event);
151151
_context.IntegrationEventLog.Add(eventLogEntry);
152152

src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedEvent.cs.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedEvent.cs renamed to src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Eve
88
// Integration Events notes:
99
// An Event is “something that has happened in the past”, therefore its name has to be
1010
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
11-
public class ProductPriceChangedEvent : IntegrationEvent
11+
public class ProductPriceChangedIntegrationEvent : IntegrationEvent
1212
{
1313
public int ProductId { get; private set; }
1414

1515
public decimal NewPrice { get; private set; }
1616

1717
public decimal OldPrice { get; private set; }
1818

19-
public ProductPriceChangedEvent(int productId, decimal newPrice, decimal oldPrice)
19+
public ProductPriceChangedIntegrationEvent(int productId, decimal newPrice, decimal oldPrice)
2020
{
2121
ProductId = productId;
2222
NewPrice = newPrice;

0 commit comments

Comments
 (0)