From 398a8d38277399fa75345dc094a112e9381957e6 Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Sat, 9 May 2026 09:03:12 +0200 Subject: [PATCH] Refactored service bus lifetiemes to singleton --- .../LiteCharms.Abstractions.csproj | 2 +- LiteCharms.Entities/LiteCharms.Entities.csproj | 2 +- .../LiteCharms.Extensions.csproj | 3 ++- LiteCharms.Extensions/Quartz.cs | 2 +- LiteCharms.Extensions/ServiceBus.cs | 11 ++++++----- .../http/midrandshop-api/http-client.env.json | 17 +++++++++++++++++ LiteCharms.Features/LiteCharms.Features.csproj | 2 +- .../LiteCharms.Infrastructure.csproj | 2 +- LiteCharms.Models/LiteCharms.Models.csproj | 2 +- LiteCharmsShared.slnx | 1 - 10 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 LiteCharms.Features.Tests/http/midrandshop-api/http-client.env.json diff --git a/LiteCharms.Abstractions/LiteCharms.Abstractions.csproj b/LiteCharms.Abstractions/LiteCharms.Abstractions.csproj index 7614de0..4074ad4 100644 --- a/LiteCharms.Abstractions/LiteCharms.Abstractions.csproj +++ b/LiteCharms.Abstractions/LiteCharms.Abstractions.csproj @@ -11,7 +11,7 @@ LiteCharms.Abstractions - 1.0.19 + 1.0.20 Khwezi Mngoma Lite Charms (PTY) Ltd Shared abstractions for Lite Charms applications. diff --git a/LiteCharms.Entities/LiteCharms.Entities.csproj b/LiteCharms.Entities/LiteCharms.Entities.csproj index 6def4d4..b32a09d 100644 --- a/LiteCharms.Entities/LiteCharms.Entities.csproj +++ b/LiteCharms.Entities/LiteCharms.Entities.csproj @@ -11,7 +11,7 @@ LiteCharms.Entities - 1.0.19 + 1.0.20 Khwezi Mngoma Lite Charms (PTY) Ltd Shared entities for Lite Charms applications. diff --git a/LiteCharms.Extensions/LiteCharms.Extensions.csproj b/LiteCharms.Extensions/LiteCharms.Extensions.csproj index 1e19321..3f531b7 100644 --- a/LiteCharms.Extensions/LiteCharms.Extensions.csproj +++ b/LiteCharms.Extensions/LiteCharms.Extensions.csproj @@ -22,7 +22,7 @@ LiteCharms.Extensions - 1.0.19 + 1.0.20 Khwezi Mngoma Lite Charms (PTY) Ltd Extension components for Lite Charms applications. @@ -49,6 +49,7 @@ + diff --git a/LiteCharms.Extensions/Quartz.cs b/LiteCharms.Extensions/Quartz.cs index a8ee941..ea71879 100644 --- a/LiteCharms.Extensions/Quartz.cs +++ b/LiteCharms.Extensions/Quartz.cs @@ -17,7 +17,7 @@ public static class Quartz { config.SchedulerName = schedulerName; config.SchedulerId = schedulerId; - + config.UseSimpleTypeLoader(); config.UseDefaultThreadPool(options => options.MaxConcurrency = 0); config.UseTimeZoneConverter(); diff --git a/LiteCharms.Extensions/ServiceBus.cs b/LiteCharms.Extensions/ServiceBus.cs index e71c074..ab8d7c0 100644 --- a/LiteCharms.Extensions/ServiceBus.cs +++ b/LiteCharms.Extensions/ServiceBus.cs @@ -1,26 +1,27 @@ using LiteCharms.Abstractions; using LiteCharms.Infrastructure.ServiceBus; using LiteCharms.Infrastructure.ServiceBus.Exchanges; +using LiteCharms.Infrastructure.ServiceBus.Queues; namespace LiteCharms.Extensions; public static class ServiceBus { public static IServiceCollection AddGeneralServiceBus(this IServiceCollection services) => services - .AddTransient() + .AddSingleton() .AddHostedService() - .AddKeyedTransient(Constants.GeneralServiceBus) + .AddKeyedSingleton(Constants.GeneralServiceBus) .AddMemoryCache(); public static IServiceCollection AddEmailServiceBus(this IServiceCollection services) => services - .AddTransient() + .AddSingleton() .AddHostedService() .AddKeyedTransient(Constants.EmailServiceBus) .AddMemoryCache(); public static IServiceCollection AddSalesServiceBus(this IServiceCollection services) => services - .AddTransient() + .AddSingleton() .AddHostedService() - .AddKeyedTransient(Constants.SalesServiceBus) + .AddKeyedSingleton(Constants.SalesServiceBus) .AddMemoryCache(); } diff --git a/LiteCharms.Features.Tests/http/midrandshop-api/http-client.env.json b/LiteCharms.Features.Tests/http/midrandshop-api/http-client.env.json new file mode 100644 index 0000000..2d5209d --- /dev/null +++ b/LiteCharms.Features.Tests/http/midrandshop-api/http-client.env.json @@ -0,0 +1,17 @@ +{ + "payfast-local": { + "baseUrl": "https://localhost:7196", + "paymentId": "jdPB2zaKM3Z", + "signature": "6aeff59bb74f2448ff2c3d81b2ec95de", + "item_name": "System Architecture Book", + "amount": "350.00" + }, + "payfast-uat": { + "baseUrl": "https://api.uat.midrandbooks.co.za", + "paymentId": "jdPB2zaKM3Z", + "signature": "6aeff59bb74f2448ff2c3d81b2ec95de", + "item_name": "System Architecture Book", + "amount": "350.00" + } +} + \ No newline at end of file diff --git a/LiteCharms.Features/LiteCharms.Features.csproj b/LiteCharms.Features/LiteCharms.Features.csproj index a0f6325..9a2a0ac 100644 --- a/LiteCharms.Features/LiteCharms.Features.csproj +++ b/LiteCharms.Features/LiteCharms.Features.csproj @@ -11,7 +11,7 @@ LiteCharms.Features - 1.0.19 + 1.0.20 Khwezi Mngoma Lite Charms (PTY) Ltd Feature components for Lite Charms applications. diff --git a/LiteCharms.Infrastructure/LiteCharms.Infrastructure.csproj b/LiteCharms.Infrastructure/LiteCharms.Infrastructure.csproj index b18410a..9647c3a 100644 --- a/LiteCharms.Infrastructure/LiteCharms.Infrastructure.csproj +++ b/LiteCharms.Infrastructure/LiteCharms.Infrastructure.csproj @@ -12,7 +12,7 @@ LiteCharms.Infrastructure - 1.0.19 + 1.0.20 Khwezi Mngoma Lite Charms (PTY) Ltd Infrastructure components for Lite Charms applications. diff --git a/LiteCharms.Models/LiteCharms.Models.csproj b/LiteCharms.Models/LiteCharms.Models.csproj index c3cd50b..95e00d1 100644 --- a/LiteCharms.Models/LiteCharms.Models.csproj +++ b/LiteCharms.Models/LiteCharms.Models.csproj @@ -11,7 +11,7 @@ LiteCharms.Models - 1.0.19 + 1.0.20 Khwezi Mngoma Lite Charms (PTY) Ltd Shared models for Lite Charms applications. diff --git a/LiteCharmsShared.slnx b/LiteCharmsShared.slnx index a08c005..91cd1e5 100644 --- a/LiteCharmsShared.slnx +++ b/LiteCharmsShared.slnx @@ -2,7 +2,6 @@ -