feat: Change RAbbitMQ Conenction to Pool and Add k6 Test Script for max request per second.

This commit is contained in:
Suphonchai Phoonsawat 2024-08-20 10:37:47 +07:00
parent 0bac3630ec
commit f5355728ab
7 changed files with 186 additions and 44 deletions

View file

@ -0,0 +1,20 @@
using BMA.EHR.Leave.Service.Services;
using Microsoft.Extensions.ObjectPool;
using RabbitMQ.Client;
namespace BMA.EHR.Leave.Service.Extensions
{
public static class RabbitMqServiceCollectionExtensions
{
public static IServiceCollection AddRabbitMqConnectionPooling(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
services.AddSingleton<ObjectPool<IModel>>(sp =>
{
var provider = sp.GetRequiredService<ObjectPoolProvider>();
return provider.Create(new RabbitMqConnectionPoolPolicy(configuration));
});
return services;
}
}
}