Skip to content

Commit

Permalink
Feature/cdms 14 (#54)
Browse files Browse the repository at this point in the history
* Expanded ASB config to support multiple subscriptions and setup a generic consumer for ALVS which routes messages based on messages.

* fixed compilations issues

* added install for docker compose

* added compose file for asb emulator

* moved docker compose files

* updated path

* updated path

* updated to start mongo after asb emulator

* changed sb connection string

* updated sb connection string

* check out azure-service-bus-emulator-installer

* fixed typo

* updates

* updates

* ignored asb smoke tests for the moment

* added health check for both subscriptions

* updated slim message bus to use the web proxy when connecting to ASB

---------

Co-authored-by: Thomas Anderson <[email protected]>
  • Loading branch information
t11omas and Thomas Anderson authored Jan 13, 2025
1 parent c454571 commit fda5e1a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Btms.Backend/Asb/AzureServiceBusHealthCheckBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,30 @@ public static IHealthChecksBuilder AddBtmsAzureServiceBusSubscription(
this IHealthChecksBuilder builder,
TimeSpan? timeout = default)
{
builder.Add(new HealthCheckRegistration(
"azuresubscription_alvs",
sp =>
{
var sbOptions = sp.GetRequiredService<IOptions<ServiceBusOptions>>();
var subscription = sbOptions.Value.AlvsSubscription;
var options = new AzureServiceBusSubscriptionHealthCheckHealthCheckOptions(subscription.Topic, subscription.Subscription)
{
ConnectionString = sbOptions.Value.ConnectionString,
UsePeekMode = true
};
return new AzureServiceBusSubscriptionHealthCheck(options, new BtmsServiceBusClientProvider(sp.GetRequiredService<IWebProxy>()));
},
default,
default,
timeout));

return builder.Add(new HealthCheckRegistration(
"azuresubscription",
"azuresubscription_notification",
sp =>
{
var sbOptions = sp.GetRequiredService<IOptions<ServiceBusOptions>>();
var firstSubscription = sbOptions.Value.Subscriptions.First();
var options = new AzureServiceBusSubscriptionHealthCheckHealthCheckOptions(firstSubscription.Value.Topic, firstSubscription.Value.Subscription)
var subscription = sbOptions.Value.NotificationSubscription;
var options = new AzureServiceBusSubscriptionHealthCheckHealthCheckOptions(subscription.Topic, subscription.Subscription)
{
ConnectionString = sbOptions.Value.ConnectionString,
UsePeekMode = true
Expand Down
11 changes: 11 additions & 0 deletions Btms.Consumers/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Net;
using Azure.Messaging.ServiceBus;
using Btms.Common.Extensions;
using Btms.Consumers.Interceptors;
using Btms.Consumers.MemoryQueue;
Expand Down Expand Up @@ -48,6 +50,15 @@ public static IServiceCollection AddConsumers(this IServiceCollection services,
{
cbb.WithProviderServiceBus(cfg =>
{
cfg.ClientFactory = (sp, settings) =>
{
var clientOptions = new ServiceBusClientOptions()
{
WebProxy = sp.GetRequiredService<IWebProxy>(),
TransportType = ServiceBusTransportType.AmqpWebSockets,
};
return new ServiceBusClient(settings.ConnectionString, clientOptions);
};
cfg.ConnectionString = serviceBusOptions?.ConnectionString;
});
cbb.AddJsonSerializer();
Expand Down

0 comments on commit fda5e1a

Please sign in to comment.