Update ServiceBus sdk from t1 to t2 (#1698)
* Update ServiceBus to the new SDKs. * resolve errors * resolve errors * update codes * update codes * add a call in constructor * remove changes * add Dispose() menthod in interface * Update codes * update the method to get topicName * Remove invalid changes * resolve the errors in service * fix issue * fix issue * update code Co-authored-by: zedy <zedy@wicresoft.com>
This commit is contained in:
parent
46219957ef
commit
c357aeac63
@ -1,58 +1,49 @@
|
|||||||
using Microsoft.Azure.ServiceBus;
|
using Azure.Messaging.ServiceBus;
|
||||||
|
using Azure.Messaging.ServiceBus.Administration;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||||
{
|
{
|
||||||
public class DefaultServiceBusPersisterConnection : IServiceBusPersisterConnection
|
public class DefaultServiceBusPersisterConnection : IServiceBusPersisterConnection
|
||||||
{
|
{
|
||||||
private readonly ServiceBusConnectionStringBuilder _serviceBusConnectionStringBuilder;
|
private readonly string _serviceBusConnectionString;
|
||||||
private readonly string _subscriptionClientName;
|
private ServiceBusClient _topicClient;
|
||||||
private SubscriptionClient _subscriptionClient;
|
private ServiceBusAdministrationClient _subscriptionClient;
|
||||||
private ITopicClient _topicClient;
|
|
||||||
|
|
||||||
bool _disposed;
|
bool _disposed;
|
||||||
|
|
||||||
public DefaultServiceBusPersisterConnection(ServiceBusConnectionStringBuilder serviceBusConnectionStringBuilder,
|
public DefaultServiceBusPersisterConnection(string serviceBusConnectionString)
|
||||||
string subscriptionClientName)
|
|
||||||
{
|
{
|
||||||
_serviceBusConnectionStringBuilder = serviceBusConnectionStringBuilder ??
|
_serviceBusConnectionString = serviceBusConnectionString;
|
||||||
throw new ArgumentNullException(nameof(serviceBusConnectionStringBuilder));
|
_subscriptionClient = new ServiceBusAdministrationClient(_serviceBusConnectionString);
|
||||||
_subscriptionClientName = subscriptionClientName;
|
_topicClient = new ServiceBusClient(_serviceBusConnectionString);
|
||||||
_subscriptionClient = new SubscriptionClient(_serviceBusConnectionStringBuilder, subscriptionClientName);
|
|
||||||
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITopicClient TopicClient
|
public ServiceBusClient TopicClient
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_topicClient.IsClosedOrClosing)
|
if (_topicClient.IsClosed)
|
||||||
{
|
{
|
||||||
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
_topicClient = new ServiceBusClient(_serviceBusConnectionString);
|
||||||
}
|
}
|
||||||
return _topicClient;
|
return _topicClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISubscriptionClient SubscriptionClient
|
public ServiceBusAdministrationClient AdministrationClient
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_subscriptionClient.IsClosedOrClosing)
|
|
||||||
{
|
|
||||||
_subscriptionClient = new SubscriptionClient(_serviceBusConnectionStringBuilder, _subscriptionClientName);
|
|
||||||
}
|
|
||||||
return _subscriptionClient;
|
return _subscriptionClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceBusConnectionStringBuilder ServiceBusConnectionStringBuilder => _serviceBusConnectionStringBuilder;
|
public ServiceBusClient CreateModel()
|
||||||
|
|
||||||
public ITopicClient CreateModel()
|
|
||||||
{
|
{
|
||||||
if (_topicClient.IsClosedOrClosing)
|
if (_topicClient.IsClosed)
|
||||||
{
|
{
|
||||||
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
_topicClient = new ServiceBusClient(_serviceBusConnectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _topicClient;
|
return _topicClient;
|
||||||
@ -63,6 +54,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
|||||||
if (_disposed) return;
|
if (_disposed) return;
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
_topicClient.DisposeAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,44 @@
|
|||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
using Azure.Messaging.ServiceBus;
|
||||||
{
|
using Azure.Messaging.ServiceBus.Administration;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Microsoft.Azure.ServiceBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Logging;
|
using System;
|
||||||
using System;
|
using System.Text.Json;
|
||||||
using System.Text;
|
using System.Threading.Tasks;
|
||||||
using System.Text.Json;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public class EventBusServiceBus : IEventBus
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||||
|
{
|
||||||
|
public class EventBusServiceBus : IEventBus, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IServiceBusPersisterConnection _serviceBusPersisterConnection;
|
private readonly IServiceBusPersisterConnection _serviceBusPersisterConnection;
|
||||||
private readonly ILogger<EventBusServiceBus> _logger;
|
private readonly ILogger<EventBusServiceBus> _logger;
|
||||||
private readonly IEventBusSubscriptionsManager _subsManager;
|
private readonly IEventBusSubscriptionsManager _subsManager;
|
||||||
private readonly ILifetimeScope _autofac;
|
private readonly ILifetimeScope _autofac;
|
||||||
|
private readonly string _topicName = "eshop_event_bus";
|
||||||
|
private readonly string _subscriptionName;
|
||||||
|
private ServiceBusSender _sender;
|
||||||
|
private ServiceBusProcessor _processor;
|
||||||
private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
|
private readonly string AUTOFAC_SCOPE_NAME = "eshop_event_bus";
|
||||||
private const string INTEGRATION_EVENT_SUFFIX = "IntegrationEvent";
|
private const string INTEGRATION_EVENT_SUFFIX = "IntegrationEvent";
|
||||||
|
|
||||||
public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection,
|
public EventBusServiceBus(IServiceBusPersisterConnection serviceBusPersisterConnection,
|
||||||
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, ILifetimeScope autofac)
|
ILogger<EventBusServiceBus> logger, IEventBusSubscriptionsManager subsManager, ILifetimeScope autofac, string subscriptionClientName)
|
||||||
{
|
{
|
||||||
_serviceBusPersisterConnection = serviceBusPersisterConnection;
|
_serviceBusPersisterConnection = serviceBusPersisterConnection;
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
|
_subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();
|
||||||
_autofac = autofac;
|
_autofac = autofac;
|
||||||
|
_subscriptionName = subscriptionClientName;
|
||||||
|
_sender = _serviceBusPersisterConnection.TopicClient.CreateSender(_topicName);
|
||||||
|
ServiceBusProcessorOptions options = new ServiceBusProcessorOptions { MaxConcurrentCalls = 10, AutoCompleteMessages = false };
|
||||||
|
_processor = _serviceBusPersisterConnection.TopicClient.CreateProcessor(_topicName, _subscriptionName, options);
|
||||||
|
|
||||||
RemoveDefaultRule();
|
RemoveDefaultRule();
|
||||||
RegisterSubscriptionClientMessageHandler();
|
RegisterSubscriptionClientMessageHandlerAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Publish(IntegrationEvent @event)
|
public void Publish(IntegrationEvent @event)
|
||||||
@ -38,14 +47,14 @@
|
|||||||
var jsonMessage = JsonSerializer.Serialize(@event, @event.GetType());
|
var jsonMessage = JsonSerializer.Serialize(@event, @event.GetType());
|
||||||
var body = Encoding.UTF8.GetBytes(jsonMessage);
|
var body = Encoding.UTF8.GetBytes(jsonMessage);
|
||||||
|
|
||||||
var message = new Message
|
var message = new ServiceBusMessage
|
||||||
{
|
{
|
||||||
MessageId = Guid.NewGuid().ToString(),
|
MessageId = Guid.NewGuid().ToString(),
|
||||||
Body = body,
|
Body = new BinaryData(body),
|
||||||
Label = eventName,
|
Subject = eventName,
|
||||||
};
|
};
|
||||||
|
|
||||||
_serviceBusPersisterConnection.TopicClient.SendAsync(message)
|
_sender.SendMessageAsync(message)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
}
|
}
|
||||||
@ -69,9 +78,9 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_serviceBusPersisterConnection.SubscriptionClient.AddRuleAsync(new RuleDescription
|
_serviceBusPersisterConnection.AdministrationClient.CreateRuleAsync(_topicName, _subscriptionName, new CreateRuleOptions
|
||||||
{
|
{
|
||||||
Filter = new CorrelationFilter { Label = eventName },
|
Filter = new CorrelationRuleFilter() { Subject = eventName },
|
||||||
Name = eventName
|
Name = eventName
|
||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
@ -95,12 +104,12 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_serviceBusPersisterConnection
|
_serviceBusPersisterConnection
|
||||||
.SubscriptionClient
|
.AdministrationClient
|
||||||
.RemoveRuleAsync(eventName)
|
.DeleteRuleAsync(_topicName, _subscriptionName, eventName)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
}
|
}
|
||||||
catch (MessagingEntityNotFoundException)
|
catch (ServiceBusException ex) when (ex.Reason == ServiceBusFailureReason.MessagingEntityNotFound)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("The messaging entity {eventName} Could not be found.", eventName);
|
_logger.LogWarning("The messaging entity {eventName} Could not be found.", eventName);
|
||||||
}
|
}
|
||||||
@ -118,32 +127,35 @@
|
|||||||
_subsManager.RemoveDynamicSubscription<TH>(eventName);
|
_subsManager.RemoveDynamicSubscription<TH>(eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
private async Task RegisterSubscriptionClientMessageHandlerAsync()
|
||||||
{
|
{
|
||||||
_subsManager.Clear();
|
_processor.ProcessMessageAsync +=
|
||||||
}
|
async (args) =>
|
||||||
|
|
||||||
private void RegisterSubscriptionClientMessageHandler()
|
|
||||||
{
|
|
||||||
_serviceBusPersisterConnection.SubscriptionClient.RegisterMessageHandler(
|
|
||||||
async (message, token) =>
|
|
||||||
{
|
{
|
||||||
var eventName = $"{message.Label}{INTEGRATION_EVENT_SUFFIX}";
|
var eventName = $"{args.Message.Subject}{INTEGRATION_EVENT_SUFFIX}";
|
||||||
var messageData = Encoding.UTF8.GetString(message.Body);
|
string messageData = args.Message.Body.ToString();
|
||||||
|
|
||||||
// Complete the message so that it is not received again.
|
// Complete the message so that it is not received again.
|
||||||
if (await ProcessEvent(eventName, messageData))
|
if (await ProcessEvent(eventName, messageData))
|
||||||
{
|
{
|
||||||
await _serviceBusPersisterConnection.SubscriptionClient.CompleteAsync(message.SystemProperties.LockToken);
|
await args.CompleteMessageAsync(args.Message);
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
new MessageHandlerOptions(ExceptionReceivedHandler) { MaxConcurrentCalls = 10, AutoComplete = false });
|
|
||||||
|
_processor.ProcessErrorAsync += ErrorHandler;
|
||||||
|
await _processor.StartProcessingAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs)
|
public void Dispose()
|
||||||
{
|
{
|
||||||
var ex = exceptionReceivedEventArgs.Exception;
|
_subsManager.Clear();
|
||||||
var context = exceptionReceivedEventArgs.ExceptionReceivedContext;
|
_processor.CloseAsync().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task ErrorHandler(ProcessErrorEventArgs args)
|
||||||
|
{
|
||||||
|
var ex = args.Exception;
|
||||||
|
var context = args.ErrorSource;
|
||||||
|
|
||||||
_logger.LogError(ex, "ERROR handling message: {ExceptionMessage} - Context: {@ExceptionContext}", ex.Message, context);
|
_logger.LogError(ex, "ERROR handling message: {ExceptionMessage} - Context: {@ExceptionContext}", ex.Message, context);
|
||||||
|
|
||||||
@ -189,14 +201,14 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_serviceBusPersisterConnection
|
_serviceBusPersisterConnection
|
||||||
.SubscriptionClient
|
.AdministrationClient
|
||||||
.RemoveRuleAsync(RuleDescription.DefaultRuleName)
|
.DeleteRuleAsync(_topicName, _subscriptionName, RuleProperties.DefaultRuleName)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
}
|
}
|
||||||
catch (MessagingEntityNotFoundException)
|
catch (ServiceBusException ex) when (ex.Reason == ServiceBusFailureReason.MessagingEntityNotFound)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("The messaging entity {DefaultRuleName} Could not be found.", RuleDescription.DefaultRuleName);
|
_logger.LogWarning("The messaging entity {DefaultRuleName} Could not be found.", RuleProperties.DefaultRuleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="6.1.0" />
|
<PackageReference Include="Autofac" Version="6.1.0" />
|
||||||
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.1.0" />
|
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.2.1" />
|
||||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
using Azure.Messaging.ServiceBus;
|
||||||
|
using Azure.Messaging.ServiceBus.Administration;
|
||||||
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||||
{
|
{
|
||||||
using Microsoft.Azure.ServiceBus;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public interface IServiceBusPersisterConnection : IDisposable
|
public interface IServiceBusPersisterConnection : IDisposable
|
||||||
{
|
{
|
||||||
ITopicClient TopicClient { get; }
|
ServiceBusClient TopicClient { get; }
|
||||||
ISubscriptionClient SubscriptionClient { get; }
|
ServiceBusAdministrationClient AdministrationClient { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Azure.Messaging.ServiceBus;
|
||||||
using Basket.API.Infrastructure.Filters;
|
using Basket.API.Infrastructure.Filters;
|
||||||
using Basket.API.IntegrationEvents.EventHandling;
|
using Basket.API.IntegrationEvents.EventHandling;
|
||||||
using Basket.API.IntegrationEvents.Events;
|
using Basket.API.IntegrationEvents.Events;
|
||||||
@ -10,7 +11,6 @@ using Microsoft.AspNetCore.Builder;
|
|||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Azure.ServiceBus;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
@ -122,10 +122,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
|
|
||||||
|
|
||||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -285,9 +283,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope);
|
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Azure.Messaging.ServiceBus;
|
||||||
using Catalog.API.Grpc;
|
using Catalog.API.Grpc;
|
||||||
using global::Catalog.API.Infrastructure.Filters;
|
using global::Catalog.API.Infrastructure.Filters;
|
||||||
using global::Catalog.API.IntegrationEvents;
|
using global::Catalog.API.IntegrationEvents;
|
||||||
@ -9,7 +10,6 @@ using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Azure.ServiceBus;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
@ -281,10 +281,9 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
|||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
|
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.EventBusConnection);
|
var serviceBusConnection = settings.EventBusConnection;
|
||||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
|
||||||
|
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
return new DefaultServiceBusPersisterConnection(serviceBusConnection);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -333,9 +332,10 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope);
|
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Setup\*">
|
<None Update="Setup\*">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
@ -1,43 +1,44 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API
|
using Microsoft.AspNetCore.Http;
|
||||||
{
|
using Autofac;
|
||||||
using AspNetCore.Http;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using Autofac;
|
using Azure.Messaging.ServiceBus;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using global::Ordering.API.Application.IntegrationEvents;
|
||||||
using global::Ordering.API.Application.IntegrationEvents;
|
using global::Ordering.API.Application.IntegrationEvents.Events;
|
||||||
using global::Ordering.API.Application.IntegrationEvents.Events;
|
using global::Ordering.API.Infrastructure.Filters;
|
||||||
using global::Ordering.API.Infrastructure.Filters;
|
using GrpcOrdering;
|
||||||
using GrpcOrdering;
|
using HealthChecks.UI.Client;
|
||||||
using HealthChecks.UI.Client;
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
|
||||||
using Infrastructure.AutofacModules;
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Filters;
|
||||||
using Infrastructure.Filters;
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
|
||||||
using Infrastructure.Services;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Azure.ServiceBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.OpenApi.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Ordering.Infrastructure;
|
||||||
using Microsoft.OpenApi.Models;
|
using RabbitMQ.Client;
|
||||||
using Ordering.Infrastructure;
|
using System;
|
||||||
using RabbitMQ.Client;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System.Data.Common;
|
||||||
using System.Collections.Generic;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Data.Common;
|
using System.IO;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.Reflection;
|
||||||
using System.IO;
|
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API
|
||||||
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
@ -297,10 +298,10 @@
|
|||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var serviceBusConnectionString = configuration["EventBusConnection"];
|
var serviceBusConnectionString = configuration["EventBusConnection"];
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
|
|
||||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
var subscriptionClientName = configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -374,9 +375,10 @@
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope);
|
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Microsoft.Azure.ServiceBus;
|
using Azure.Messaging.ServiceBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
@ -54,9 +54,8 @@ namespace Ordering.BackgroundTasks.Extensions
|
|||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var serviceBusConnectionString = configuration["EventBusConnection"];
|
var serviceBusConnectionString = configuration["EventBusConnection"];
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
|
|
||||||
|
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||||
@ -65,8 +64,9 @@ namespace Ordering.BackgroundTasks.Extensions
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, iLifetimeScope);
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Azure.Messaging.ServiceBus;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Azure.ServiceBus;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
@ -65,11 +65,10 @@ namespace Ordering.SignalrHub
|
|||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
|
|
||||||
|
|
||||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -213,9 +212,10 @@ namespace Ordering.SignalrHub
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope);
|
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Azure.Messaging.ServiceBus;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.Azure.ServiceBus;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
@ -41,10 +41,9 @@ namespace Payment.API
|
|||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
var serviceBusConnectionString = Configuration["EventBusConnection"];
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
|
|
||||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -130,9 +129,10 @@ namespace Payment.API
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = Configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope);
|
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Azure.Messaging.ServiceBus;
|
||||||
using Devspaces.Support;
|
using Devspaces.Support;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Azure.ServiceBus;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
@ -215,9 +215,10 @@ namespace Webhooks.API
|
|||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
string subscriptionName = configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope);
|
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -285,9 +286,8 @@ namespace Webhooks.API
|
|||||||
{
|
{
|
||||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||||
{
|
{
|
||||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(configuration["EventBusConnection"]);
|
|
||||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
var subscriptionClientName = configuration["SubscriptionClientName"];
|
||||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, subscriptionClientName);
|
return new DefaultServiceBusPersisterConnection(configuration["EventBusConnection"]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
2026
src/Web/WebSPA/Client/package-lock.json
generated
2026
src/Web/WebSPA/Client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user