spring-bootconfigurationspring-amqp

Get values of spring rabbitmq config properties programmatically?


Is there a way to get the values of the various spring.rabbitmq config properties (like spring.rabbitmq.virtual-host) programmatically other than via @Value (like ApplicationContext.getApplicationName())?


Solution

  • Those spring.rabbitmq are part of Spring Boot auto-configuration. So, you simply can inject a RabbitProperties bean and have access to them.

    See more info in Spring Boot docs: https://docs.spring.io/spring-boot/reference/messaging/amqp.html#messaging.amqp.rabbitmq