Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On (re-)initialization, static Declarables should be re-declared before manually declared ones #2815

Closed
sherter opened this issue Sep 13, 2024 · 1 comment · Fixed by #2829

Comments

@sherter
Copy link

sherter commented Sep 13, 2024

In what version(s) of Spring AMQP are you seeing this issue?
3.1.6

Describe the bug

I call RabbitAdmin#setRedeclareManualDeclarations(true) to ensure that any Exchanges, Queues or Bindings I declare at runtime (with
AmqpAdmin#declareExchange/declareQueue/declareBinding) are automatically re-declared when rabbitmq looses its state for some reason.

I also have some static Exchanges, which I bind as @Bean in the application context. Spring implicitly takes care of declaring those for me.

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.

Expected behavior
Statically configured declarations should be recreated first and the manualDeclarables should be redeclared afterwards.

** Workaround exists
For now, I can just call AmpqAdmin.declareExchange once on startup for the static Exchange, so that it will be redeclared as part of redeclareManualDeclarables(), but IMHO I shouldn't have to do that.

@sherter sherter changed the title On (re-)initialization, static Declarables should be re-declared _before_ manually declared Declarables On (re-)initialization, static Declarables should be re-declared before manually declared Declarables Sep 13, 2024
@sherter sherter changed the title On (re-)initialization, static Declarables should be re-declared before manually declared Declarables On (re-)initialization, static Declarables should be re-declared before manually declared ones Sep 13, 2024
@artembilan artembilan added this to the 3.2.0-M3 milestone Sep 13, 2024
@artembilan
Copy link
Member

Sounds line a plan!
Feel free to contribute the fix: https://github.com/spring-projects/spring-amqp/blob/main/CONTRIBUTING.adoc

Thanks

artembilan pushed a commit that referenced this issue Sep 16, 2024
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()`

**Auto-cherry-pick to `3.1.x`**
spring-builds pushed a commit that referenced this issue Sep 16, 2024
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants