Update codes
This commit is contained in:
parent
0709a3ce5b
commit
e7ea0109e4
@ -19,7 +19,5 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||
void Unsubscribe<T, TH>()
|
||||
where TH : IIntegrationEventHandler<T>
|
||||
where T : IntegrationEvent;
|
||||
|
||||
void Dispose();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Polly;
|
||||
using Polly.Retry;
|
||||
using RabbitMQ.Client;
|
||||
@ -28,7 +27,6 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
|
||||
private readonly IEventBusSubscriptionsManager _subsManager;
|
||||
private readonly ILifetimeScope _autofac;
|
||||
private readonly int _retryCount;
|
||||
private readonly ServiceBusProcessor _processor;
|
||||
|
||||
private IModel _consumerChannel;
|
||||
private string _queueName;
|
||||
@ -44,7 +42,6 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
|
||||
_autofac = autofac;
|
||||
_retryCount = retryCount;
|
||||
_subsManager.OnEventRemoved += SubsManager_OnEventRemoved;
|
||||
this._processor = EventBusServiceBus.EventBusServiceBus.DeliverProcessor();
|
||||
}
|
||||
|
||||
private void SubsManager_OnEventRemoved(object sender, string eventName)
|
||||
@ -181,7 +178,6 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ
|
||||
}
|
||||
|
||||
_subsManager.Clear();
|
||||
_processor.CloseAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private void StartBasicConsume()
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.2.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Polly" Version="7.2.1" />
|
||||
@ -15,7 +14,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EventBusServiceBus\EventBusServiceBus.csproj" />
|
||||
<ProjectReference Include="..\EventBus\EventBus.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -55,6 +55,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||
if (_disposed) return;
|
||||
|
||||
_disposed = true;
|
||||
_topicClient.DisposeAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||
{
|
||||
public class EventBusServiceBus : IEventBus
|
||||
public class EventBusServiceBus : IEventBus, IDisposable
|
||||
{
|
||||
private readonly IServiceBusPersisterConnection _serviceBusPersisterConnection;
|
||||
private readonly ILogger<EventBusServiceBus> _logger;
|
||||
@ -20,7 +20,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||
private readonly string _topicName;
|
||||
private readonly string _subscriptionName;
|
||||
private ServiceBusSender _sender;
|
||||
private static ServiceBusProcessor _processor;
|
||||
private ServiceBusProcessor _processor;
|
||||
private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
|
||||
private const string INTEGRATION_EVENT_SUFFIX = "IntegrationEvent";
|
||||
|
||||
@ -131,11 +131,6 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||
_processor.CloseAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static ServiceBusProcessor DeliverProcessor()
|
||||
{
|
||||
return _processor;
|
||||
}
|
||||
|
||||
private async Task RegisterSubscriptionClientMessageHandlerAsync()
|
||||
{
|
||||
_processor.ProcessMessageAsync +=
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Basket.API.Infrastructure.Filters;
|
||||
using Basket.API.IntegrationEvents.EventHandling;
|
||||
using Basket.API.IntegrationEvents.Events;
|
||||
@ -122,7 +123,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
||||
{
|
||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||
|
||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
|
||||
});
|
||||
}
|
||||
@ -283,8 +283,9 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
|
@ -50,6 +50,7 @@
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.1" />
|
||||
<PackageReference Include="Azure.Identity" Version="1.4.0" />
|
||||
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.2.0" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.34.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.34.0" PrivateAssets="All" />
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Catalog.API.Grpc;
|
||||
using global::Catalog.API.Infrastructure.Filters;
|
||||
using global::Catalog.API.IntegrationEvents;
|
||||
@ -331,8 +332,9 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
|
@ -1,42 +1,44 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API
|
||||
{
|
||||
using AspNetCore.Http;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using global::Ordering.API.Application.IntegrationEvents;
|
||||
using global::Ordering.API.Application.IntegrationEvents.Events;
|
||||
using global::Ordering.API.Infrastructure.Filters;
|
||||
using GrpcOrdering;
|
||||
using HealthChecks.UI.Client;
|
||||
using Infrastructure.AutofacModules;
|
||||
using Infrastructure.Filters;
|
||||
using Infrastructure.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Ordering.Infrastructure;
|
||||
using RabbitMQ.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using global::Ordering.API.Application.IntegrationEvents;
|
||||
using global::Ordering.API.Application.IntegrationEvents.Events;
|
||||
using global::Ordering.API.Infrastructure.Filters;
|
||||
using GrpcOrdering;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Filters;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Ordering.Infrastructure;
|
||||
using RabbitMQ.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
@ -373,8 +375,9 @@
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Autofac;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||
@ -63,8 +64,9 @@ namespace Ordering.BackgroundTasks.Extensions
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@ -211,8 +212,9 @@ namespace Ordering.SignalrHub
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
@ -128,8 +129,9 @@ namespace Payment.API
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Azure.Messaging.ServiceBus;
|
||||
using Devspaces.Support;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
@ -214,8 +215,9 @@ namespace Webhooks.API
|
||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
string topicName = "topicName";
|
||||
string subscriptionName = "subscriptionName";
|
||||
var serviceBusConnectionString = configuration["EventBusConnection"];
|
||||
string topicName = ServiceBusConnectionStringProperties.Parse(serviceBusConnectionString).EntityPath;
|
||||
string subscriptionName = configuration["SubscriptionClientName"];
|
||||
|
||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||
eventBusSubcriptionsManager, iLifetimeScope, topicName, subscriptionName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user