Search code examples
rabbitmqspring-amqpspring-rabbit

Can I update AMQP settings in runtime?


I have specific requirements: needed application that can change connection settings and listened queues in runtime.

I want to use Spring AMQP abstractions: CachingConnectionFactory, DirectMessageListenerContainer, RabbitTemplate, AsyncRabbitTemplate that application will update in runtime.

CachingConnectionFactory - update address, username and password. DirectMessageListenerContainer - update QueueNames. Last ones - will not updated, but affected by ConnectionFactory.

Is it correct way? Or I should use base implementation with consumers?


Solution

    • stop all activity that uses the broker (listener containers, producers)
    • cachingConnectionFactory.resetConnection()
    • reconfigure connection factory
    • add and remove queues to/from the containers
    • start containers and producers