Description
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)
if (this.messagingMessageConverter.method == null && amqpMessage != null) {
amqpMessage.getMessageProperties().setTargetMethod(this.handlerAdapter.getMethodFor(message.getPayload()));
}
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.