Remove unneeded local variable.

This commit is contained in:
José Alberto 2018-05-30 22:51:49 +02:00
parent 8b846968e2
commit 44f43cdc0d

View File

@ -22,7 +22,7 @@
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"; 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,
ILifetimeScope autofac) ILifetimeScope autofac)
{ {
@ -30,7 +30,7 @@
_logger = logger; _logger = logger;
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
_subscriptionClient = new SubscriptionClient(serviceBusPersisterConnection.ServiceBusConnectionStringBuilder, _subscriptionClient = new SubscriptionClient(serviceBusPersisterConnection.ServiceBusConnectionStringBuilder,
subscriptionClientName); subscriptionClientName);
_autofac = autofac; _autofac = autofac;
@ -68,7 +68,7 @@
where T : IntegrationEvent where T : IntegrationEvent
where TH : IIntegrationEventHandler<T> where TH : IIntegrationEventHandler<T>
{ {
var eventName = typeof(T).Name.Replace(INTEGRATION_EVENT_SUFIX, ""); var eventName = typeof(T).Name.Replace(INTEGRATION_EVENT_SUFIX, "");
var containsKey = _subsManager.HasSubscriptionsForEvent<T>(); var containsKey = _subsManager.HasSubscriptionsForEvent<T>();
if (!containsKey) if (!containsKey)
@ -81,7 +81,7 @@
Name = eventName Name = eventName
}).GetAwaiter().GetResult(); }).GetAwaiter().GetResult();
} }
catch(ServiceBusException) catch (ServiceBusException)
{ {
_logger.LogInformation($"The messaging entity {eventName} already exists."); _logger.LogInformation($"The messaging entity {eventName} already exists.");
} }
@ -129,10 +129,9 @@
{ {
var eventName = $"{message.Label}{INTEGRATION_EVENT_SUFIX}"; var eventName = $"{message.Label}{INTEGRATION_EVENT_SUFIX}";
var messageData = Encoding.UTF8.GetString(message.Body); var messageData = Encoding.UTF8.GetString(message.Body);
var processed = await ProcessEvent(eventName, messageData);
// Complete the message so that it is not received again. // Complete the message so that it is not received again.
if (processed) if (await ProcessEvent(eventName, messageData))
{ {
await _subscriptionClient.CompleteAsync(message.SystemProperties.LockToken); await _subscriptionClient.CompleteAsync(message.SystemProperties.LockToken);
} }
@ -197,4 +196,4 @@
} }
} }
} }
} }