8000 GitHub - anehir/PooledRabbitClient: An ObjectPool implementation of .Net RabbitMQ Client library's Channel class.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

anehir/PooledRabbitClient

< 8000 /div>

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PooledRabbitClient

An ObjectPool addition to the RabbitMQ .Net Client library. You basically have a pool of channels. You pick a channel when you need and return after publishing your message.

I found below article when I needed a multiple channel publisher implementation for performance concerns:

https://www.c-sharpcorner.com/article/publishing-rabbitmq-message-in-asp-net-core/

So, I gathered all the codes in the article above and added some extra to form a class library and used it in my projects.

Sample usage on a .Net WebApi project:

    public class Startup
    {
        ...
        
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddRabbit(new RabbitOptions()
            {
                UserName = "***",
                Password = "***",
                HostName = "localhost",
                VHost = "/",
                Port = 5672
            });
        }
        
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var rabbitClient = app.ApplicationServices.GetServi
648F
ce<IRabbitManager>();
            rabbitClient.QueueDeclare("hello", true, false, true, null);
            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }
    
    [Route("api/[controller]")]
    [ApiController]
    public class QueueController : ControllerBase
    {
        private IRabbitManager _rabbitClient;

        public QueueController(IRabbitManager rabbitClient)
        {
            _rabbitClient = rabbitClient;
        }
        
        [HttpPost]
        public void Post([FromBody] string value)
        {
            _rabbitClient.Publish<string>(value, "", "hello");
        }
        
        ...
    }

About

An ObjectPool implementation of .Net RabbitMQ Client library's Channel class.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0