java操作RabbitMq时出现Caused by: org.springframework.amqp.AmqpException: Cannot determine ReplyTo message

今天使用java对@RabbitMq消息中间件的队列进行监听的时候出现一个异常

Caused by: org.springframework.amqp.rabbit.listener.adapter.ReplyFailureException: Failed to send reply with payload 'InvocationResult [returnValue=true, returnType=boolean]'
	at org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.doHandleResult(AbstractAdaptableMessageListener.java:426) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.handleResult(AbstractAdaptableMessageListener.java:358) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:131) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1542) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	... 10 common frames omitted
Caused by: org.springframework.amqp.AmqpException: Cannot determine ReplyTo message property value: Request message does not contain reply-to property, and no default response Exchange was set.
	at org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.getReplyToAddress(AbstractAdaptableMessageListener.java:506) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.doHandleResult(AbstractAdaptableMessageListener.java:422) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	... 13 common frames omitted

 

出错的原因是:@RabbitListener注解修饰监听的方法添加了返回值。

RabbitListener修饰的方法,即队列的监听函数,不能返回任何值!否则会导致一个rabbit reply message  回复异常,
* 该异常是由于此方法返回的消息没有设置目的地

 

解决:只要把监听的方法的返回值改为void即可。

注意:监听方法返回值必须为void

    @RabbitListener(queues = "deleteHtml") //监听deleteHtml消息队列
    @RabbitHandler
    public void deleteItemHtml(String ids) {
      

    }

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值