码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot整合RabbitMQ出现org.springframework.amqp.AmqpException: No method found for class

时间:2019-12-30 19:20:34      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:直接   ram   consumer   解决方法   dap   use   abstract   fanout   报错   

@Component
@RabbitListener(queues="my_fanout")
public class Consumer {

    @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=”my_fanout”)不需要放在类上。直接注释在方法上就好 @Component public class Consumer { @RabbitListener(queues="my_fanout")     public void process(Message message){         System.out.println(new String(message.getBody()));     } }

SpringBoot整合RabbitMQ出现org.springframework.amqp.AmqpException: No method found for class

标签:直接   ram   consumer   解决方法   dap   use   abstract   fanout   报错   

原文地址:https://www.cnblogs.com/yang-xiansen/p/12121191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!