java-spring-rabbitmq icon indicating copy to clipboard operation
java-spring-rabbitmq copied to clipboard

Support for multiple RabbitTemplate beans in the ApplicationContext

Open sudr opened this issue 6 years ago • 12 comments

Currently the Spring Boot auto configuration will blow up on applicaiton startup if there is more than one bean of type RabbitTemplate. It would seem useful to support a collection of RabbitTemplate beans instead for applications that have multiple RabbitTemplate beans.

https://github.com/opentracing-contrib/java-spring-rabbitmq/blob/904bd38465c790a362740ceb8cf4f7f532d35ada/opentracing-spring-rabbitmq-starter/src/main/java/io/opentracing/contrib/spring/rabbitmq/RabbitMqTracingAutoConfiguration.java#L43

sudr avatar Jan 14 '19 22:01 sudr

Do you want to submit a PR for the next release?

ask4gilles avatar Feb 21 '19 06:02 ask4gilles

I've since disabled Spring Boot's RabbitMQ AutoConfiguration for other reasons and so don't have a pressing need for this. If I have time next week I can take a look into solving this.

sudr avatar Feb 21 '19 17:02 sudr

Looking forward to this feature.

wuyupengwoaini avatar Feb 28 '19 09:02 wuyupengwoaini

I just did some tests with several rabbit templates defined and it works now. Feel free to reopen this if needed.

ask4gilles avatar Jun 12 '19 10:06 ask4gilles

@ask4gilles Hi, i have this trouble right now. In io.opentracing.contrib.spring.rabbitmq.RabbitMqTracingAutoConfiguration bean with name rabbitMqSendTracingAspect required a single bean of rabbitTemplate. Could you check this for now, please?

arseny-tl avatar Jun 01 '20 14:06 arseny-tl

Also, i got the idea how to fix this - simply use ((RabbitTemplate) pjp.getTarget()).getMessageConverter and so on in aspect.

arseny-tl avatar Jun 01 '20 16:06 arseny-tl

@ask4gilles i want to try my best in my pull-request with changes. Currently, i have some work done with aspect + unit test, but have no idea how to write IT test with multiple RabbitTemplate beans. Can you help me with that? In my mind, i should create configuration with some rabbitTemplate beans in it, and then try to publish/publishAndRecieve messages, using both rabbit templates, and assert that both of them trace message. How can i organize my work on it, using already existing test utils?

arseny-tl avatar Jun 07 '20 16:06 arseny-tl

@arseny-tl Thank you for raising this PR! I'll try to find some time this week to have a look at it. Perhaps @sudr could also double check?

ask4gilles avatar Jun 09 '20 11:06 ask4gilles

anything update?

zouyx avatar Jun 24 '21 05:06 zouyx

please any update on this? @ask4gilles. @sudr were you able to find a workaround? thanks

folaraz avatar Nov 27 '22 15:11 folaraz

@folaraz This project is not maintained anymore

ask4gilles avatar Nov 30 '22 07:11 ask4gilles

got it thanks @ask4gilles. is this due to the migration over to opentelemetry? if yes, please what spring boot dependencies would achieve this same result as this library? thanks

folaraz avatar Nov 30 '22 10:11 folaraz