Open Closed

Update RabbitMq options at Runtime #2642


User avatar
0
gizemozdemir created
  • ABP Framework version: v5.0.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

Hi,

We are using AbpRabbitMqModule, AbpEventBusRabbitMqModule modules for eventbus messaging . We want to update AbpRabbitMqOptions HostName at runtime with user input. We are using appsettings.json to configuration. Is updating appsettings.json enough ?

I attached related part of our code .What is the best way to do that? Is there a way to reconfigure a module at runtime and reinitialize it? Thanks a lot.


4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    You can inject the IOptions<AbpRabbitMqOptions> to change it.

  • User Avatar
    0
    gizemozdemir created

    Hi liangshiwei,

    Thx for your answer, I have tried IOptions and IOptionsSnapshot also. We can update value, but connections is not refreshed or updated with new hostname. Am i missing something ?

    Regards. Mehmet

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The connection is not cheeped, so we use IConnectionPool. it will reuse as many connections as possible.

    You can replace IConnectionPool with your own implementation to create a new connection when the HostName is changed.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs

  • User Avatar
    0
    gizemozdemir created

    Hi,

    Thank you. I get it.

    Regards.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15