Search code examples
spring-bootspring-cloud-streamspring-cloud-config

How to do Spring Cloud Steam Binder SPI resilience?


Initially configured following properties from application.properties:

spring.cloud.stream.defaultBinder: XXXXX spring.cloud.stream.binders.XXXXX.type : rabbit spring.cloud.stream.binders.XXXXX.environment.spring.rabbitmq.addresses : spring.cloud.stream.binders.XXXXX.environment.spring.rabbitmq.username : ppp spring.cloud.stream.binders.XXXXX.environment.spring.rabbitmq.password : qqqq spring.cloud.stream.binders.XXXXX.environment.spring.rabbitmq.virtual-host : /com/llll/ccc

Later i would like to change spring.cloud.stream.binders.XXXXX.environment.spring.rabbitmq.addresses without stopping the server. I tried following way:

@Autowired
private EnvironmentManager poEnvironmentManager = null;

and the in the method 

poEnvironmentManager.setProperty("spring.cloud.stream.binders.XXXXX.environment.spring.rabbitmq.addresses", ".......");

It was not working. Let me know if you have solution.


Solution

  • You can't just change that property on the fly. It would mean that a new connection factory had to be created, probably a refresh of the application context. What were you trying to achieve here, switch the target broker at runtime?