-
Notifications
You must be signed in to change notification settings - Fork 638
GH-2428: Manual Declarations Recovery #2429
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
GH-2428: Manual Declarations Recovery #2429
Conversation
@EldarErel Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@EldarErel Thank you for signing the Contributor License Agreement! |
5c7045e
to
dc55654
Compare
dc55654
to
f9d1767
Compare
@EldarErel Why is there no This is a Spring project and is designed for use in a Spring application; there are probably many other features that won't work when used outside of Spring. I am not inclined to accept a change that would support/promote such usage because it could be a slippery slope and become a support nightmare. If you don't want to use Spring, consider using the amqp-client API directly. If you are using it in a Spring app, then the admin must be declared as a bean so that all of its I'll leave this open for a short while, in case you can provide a compelling use case for us to accep this change. |
Hi @garyrussell , thank you for your quick response. I use spring, the use case is trying to create several listeners to several connections, I’ve created a connection, listener container and amqp admin for each connection. As I created the beans myself, I skipped the setter of the application context in the amqp admin As you added manual declaration for non bean declarables, I thought it will be reasonable to use an AmqpAdmin bean for manual declarations only. If application context is needed to use the manual declarations recovery, then maybe it should be enforced on initialization of a new RabbitAdmin instance. |
|
It’s not a Spring bean if you just create it yourself, it’s just an instance of the class. |
I created a bean for mapping the rabbitAdmins by the connection name: for example:
then, I use I didn't register each of the admins as bean, just the whole map. (Maybe I should have done it.) So I expected it to work. |
With the spring support, upon connection recovery, the admin |
Adding a @Bean
Map<String, RabbitAdmin> admins(ConfigurableApplicationContext context, ConnectionFactory cf) {
RabbitAdmin admin = new RabbitAdmin(cf);
context.getBeanFactory().registerSingleton("foo", admin);
admin = (RabbitAdmin) context.getBeanFactory().initializeBean(admin, "foo");
return Map.of("foo", admin);
} |
Thank you very much for your time and response! If the admin cannot functional without it being a bean, so ok I understand. |
Ok; I can make an exception this time, but please be aware that other features won't work either (e.g. publication of |
Well understood, (how can the event be sent without publisher and the context?) |
That's what I am saying; if it's not a bean (and you don't provide a publisher), there are no events published... spring-amqp/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java Lines 909 to 911 in ba9f8a1
|
exactly, well understood and it make sense. We cannot expect publishing of events without a publisher. But we can expect manual re declaration without application context (as it is not necessary for the flow) |
Issue link: #2428
Fixes an issue when manual declarations are not being redeclared upon connection recovery, when application context has not been set