-
Notifications
You must be signed in to change notification settings - Fork 626
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
AmqpException when testing @RabbitListener with @RabbitHandler #2456
Comments
Might indeed be a case. Well, let's see if Your project is too complex to give an immediate advice... |
Hello Artem, thanks for the fast answer. I saw the linked documentation and have also downloaded the four files from the GitHub repo:
Only TestRabbitTemplateTests works well, but this kind of test I already have. I am interested in the other test where Then I downloaded the whole project Spring AMQP(spring-amqp-dist) and there the reference is also marked with the same message. I have tried to debug the tests and only TestRabbitTemplateTests could be debugged. The other tests are skipped. Should that be that way? |
The Those tests does not pass for your because you don't have a RabbitMQ broker on the default host/port. However you probably can combine both |
Perhaps that is just a warning from your IDE because it doesn't understand what the |
Reproduced by returning a spy here: Lines 1979 to 1982 in ee681bd
As stated, all methods are doubled up; in this case I get
Looks like we need to add code to the BPP to ignore methods from classes containing Spy method: public java.lang.String org.springframework.amqp.rabbit.annotation.EnableRabbitIntegrationTests$MultiListenerBean$MockitoMock$m0IRDAeN.defaultHandler(java.lang.Object) Real method: public java.lang.String org.springframework.amqp.rabbit.annotation.EnableRabbitIntegrationTests$MultiListenerBean.defaultHandler(java.lang.Object) |
But if we do that then purpose of the |
Probably, yes; need to figure out what works (might need to filter out the non-mock methods) - but I am currently seeing another strange side-effect of making the bean a spy - when the queue name is anonymous, I am getting 2 containers/anonymous queues. If I name the queue, I only get one container. Very strange. |
I am off work tomorrow so may have to revisit this later this week. |
The duplicate container issue is because we see 2 class level |
It all works fine; PR soon. |
Resolves spring-projects#2456 When spying a `@RabbitListener` bean, duplicate methods are resolved as well as duplicate class level `@RabbitListener` annotations. **cherry-pick to 2.4.x** (will require instanceof polishing for Java 8)
Resolves #2456 When spying a `@RabbitListener` bean, duplicate methods are resolved as well as duplicate class level `@RabbitListener` annotations. **cherry-pick to 2.4.x** (will require instanceof polishing for Java 8)
Resolves #2456 When spying a `@RabbitListener` bean, duplicate methods are resolved as well as duplicate class level `@RabbitListener` annotations. **cherry-pick to 2.4.x** (will require instanceof polishing for Java 8)
Thanks for the work, Gary and Artem. I wrote I found that issue in version 3.0.6, but it was the version of the pring-boot-starter-parent project. The version of the spring-amqp-dist project used there is 3.0.4, and of course, its modules, but the change is committed in the 3.0.5-SNAPSHOT. When will the modification be part of the spring-boot-starter-amqp? |
June 19, with Boot to follow a couple of days later. https://github.com/spring-projects/spring-amqp/milestones |
The framework is intended for use with Spring Framework 5.3. However, this change was the only thing preventing it being used with 5.2.
The framework is intended for use with Spring Framework 5.3. However, this change was the only thing preventing it being used with 5.2.
In what version(s) of Spring AMQP are you seeing this issue?
3.0.6
Describe the bug
I am not sure if it is a bug but I can not explain the thrown exception
Caused by: org.springframework.amqp.AmqpException: Ambiguous methods for payload type
for the given situation.On integration test with test containers and spying a class with Mockito annotated with @RabbitListener and its methods annotated with @RabbitHandler leads to AmqpException.
Obviously, the original @RabbitHanlder method is loaded and the mocked one at the same time.
MessagingMessageListenerAdapter::invokeHandlerAndProcessResult at line 140 (this.handlerAdapter.delegatingHanlder)
It there anything I can do to avoid this situation?
To Reproduce
You need to start the tests which are located in the linked project.
Expected behavior
I would not expect the error since the methods are not loaded twice.
Sample
Starting the DifferentTypesDistributorListenerIntegrationTest or ManyCustomersWorkersSpyListenerIntegrationTest from the project led to the exception https://github.com/kstojanovski-novatec/spring-amqp-testing-issue.
The text was updated successfully, but these errors were encountered: