Skip to content

Commit

Permalink
GH-2815: Fix RabbitAdmin for static `Declarables
Browse files Browse the repository at this point in the history
Fixes: #2815
Issue link: #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()`

(cherry picked from commit 2ebc7ef)
  • Loading branch information
ngocnhan-tran1996 authored and spring-builds committed Sep 16, 2024
1 parent e678b88 commit 6fab5fb
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
* @author Gary Russell
* @author Artem Bilan
* @author Christian Tzolov
* @author Ngoc Nhan
*/
@ManagedResource(description = "Admin Tasks")
public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, ApplicationEventPublisherAware,
Expand Down Expand Up @@ -648,8 +649,14 @@ public void afterPropertiesSet() {
@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;
Expand Down

0 comments on commit 6fab5fb

Please sign in to comment.