首页 > 编程语言 > 详细

spring boot整合rabbitmq踩坑 Caused by: org.springframework.amqp.AmqpException: No method found for class

时间:2020-06-07 15:54:26      阅读:43      评论:0      收藏:0      [点我收藏+]

按照官方的例子代码如下:

@Component
@RabbitListener(queues="test_mq_testQueue")
public class Receiver {


    @RabbitHandler 
    public void process(String msg){
        System.out.println(msg);
    }
}
但是运行接收消息时,后台一直循环报错

Caused by: org.springframework.amqp.AmqpException: No method found for class [B
    at org.springframework.amqp.rabbit.listener.adapter.DelegatingInvocableHandler.getHandlerForPayload(DelegatingInvocableHandler.java:127)
    at org.springframework.amqp.rabbit.listener.adapter.DelegatingInvocableHandler.getMethodNameFor(DelegatingInvocableHandler.java:224)
    at org.springframework.amqp.rabbit.listener.adapter.HandlerAdapter.getMethodAsString(HandlerAdapter.java:61)
    at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:140)
    at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:106)
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:822)
    ... 10 common frames omitted


后来查资料发现,@RabbitListener(queues=”test_mq_testQueue”)不需要放在类上。直接注释在方法上就好

@Component
public class Receiver {
@RabbitListener(queues="test_mq_testQueue")
    public void process(Message message){
        System.out.println(new String(message.getBody()));
    }
}

spring boot整合rabbitmq踩坑 Caused by: org.springframework.amqp.AmqpException: No method found for class

原文:https://www.cnblogs.com/linliquan/p/13060727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!