GH-2815: Fix RabbitAdmin for static `Declarables
Fixes: #2815 Issue link: https://github.com/spring-projects/spring-amqp/issues/2815 When rabbitmq resets, `RabbitAdmin#initialize` calls `redeclareManualDeclarables()` first, before it continues with re-declaring statically configured declarations. This means that explicitly declared Bindings to statically declared Exchanges can never be restored, because the Exchange has to exist in order for the Binding declaration to succeed. * Call new `redeclareBeanDeclarables()` before `redeclareManualDeclarables()` **Auto-cherry-pick to `3.1.x`**
This commit is contained in:
@@ -81,6 +81,7 @@ import com.rabbitmq.client.Channel;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
@ManagedResource(description = "Admin Tasks")
|
||||
public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, ApplicationEventPublisherAware,
|
||||
@@ -648,8 +649,14 @@ public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, Applicat
|
||||
@Override // NOSONAR complexity
|
||||
public void initialize() {
|
||||
|
||||
redeclareBeanDeclarables();
|
||||
redeclareManualDeclarables();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process bean declarables.
|
||||
*/
|
||||
private void redeclareBeanDeclarables() {
|
||||
if (this.applicationContext == null) {
|
||||
this.logger.debug("no ApplicationContext has been set, cannot auto-declare Exchanges, Queues, and Bindings");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user