I am using spring-boot
and spring-rabbitmq
package. I have some config class and class representing client. This client class has one listener annotated with @RabbitListener
. Everything is fine with my config and client - it does work.
However, I need to know some details about internals of this client class. Is something special set in a context ? I would like to be able to inject one of three available datasources (three beans). I mean that I would like to be able based on the first symbol of message (thanks to custom converter I can assume that this symbol happens) that actual datasource bean will be injected/used.
Any ideas? Maybe spring-rabbitmq
modifies in some way context ?
The class with
@RabbitListener
must be declared as a bean in application context (either way - out of scope of the question). And it must besingleton
- created only once object. Therefore all the injections must be done during its instantiation/initialization.So, during that
@RabbitListener
method invocation you should just choose a properDataSource
, for example from the:What you describe in your question isn't a behavior of Spring Dependency Injection Container.