Browse Source

Reduce the integration event name

pull/255/head
Christian Arenas 7 years ago
parent
commit
975b85129e
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs

+ 5
- 3
src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs View File

@ -22,6 +22,7 @@
private readonly SubscriptionClient _subscriptionClient; private readonly SubscriptionClient _subscriptionClient;
private readonly ILifetimeScope _autofac; private readonly ILifetimeScope _autofac;
private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus"; private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
private const string INTEGRATION_EVENT_SUFIX = "IntegrationEvent";
public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection, public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection,
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, string subscriptionClientName, ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, string subscriptionClientName,
@ -41,7 +42,7 @@
public void Publish(IntegrationEvent @event) public void Publish(IntegrationEvent @event)
{ {
var eventName = @event.GetType().Name;
var eventName = @event.GetType().Name.Replace(INTEGRATION_EVENT_SUFIX, "");
var jsonMessage = JsonConvert.SerializeObject(@event); var jsonMessage = JsonConvert.SerializeObject(@event);
var body = Encoding.UTF8.GetBytes(jsonMessage); var body = Encoding.UTF8.GetBytes(jsonMessage);
@ -69,7 +70,8 @@
where T : IntegrationEvent where T : IntegrationEvent
where TH : IIntegrationEventHandler<T> where TH : IIntegrationEventHandler<T>
{ {
var eventName = typeof(T).Name;
var eventName = typeof(T).Name.Replace(INTEGRATION_EVENT_SUFIX, "");
var containsKey = _subsManager.HasSubscriptionsForEvent<T>(); var containsKey = _subsManager.HasSubscriptionsForEvent<T>();
if (!containsKey) if (!containsKey)
{ {
@ -94,7 +96,7 @@
where T : IntegrationEvent where T : IntegrationEvent
where TH : IIntegrationEventHandler<T> where TH : IIntegrationEventHandler<T>
{ {
var eventName = typeof(T).Name;
var eventName = typeof(T).Name.Replace(INTEGRATION_EVENT_SUFIX, "");
try try
{ {


Loading…
Cancel
Save