springAMQP接收消息报错

发布时间:2024年01月11日

报错问题

01-10 23:04:33:471  WARN 14400 --- [ntContainer#0-1] o.s.a.r.listener.BlockingQueueConsumer   : Failed to declare queue: simple,queue
01-10 23:04:33:474  WARN 14400 --- [ntContainer#0-1] o.s.a.r.listener.BlockingQueueConsumer   : Queue declaration failed; retries left=3

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[simple,queue]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:712) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.passiveDeclarations(BlockingQueueConsumer.java:595) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:582) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1356) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1201) ~[spring-rabbit-2.2.15.RELEASE.jar:2.2.15.RELEASE]
	at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: java.io.IOException: null

大家请看下面代码找出不同

代码一


@Component
public class SpringRabbitListener {
    @RabbitListener(queues = "simple,queue")
    public void listenSimpleQueue(String msg){
        System.out.println("消费者接收到simple.queue的消息:{"+msg+"}");

    }

}

代码二


@Component
public class SpringRabbitListener {
    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(String msg){
        System.out.println("消费者接收到simple.queue的消息:{"+msg+"}");

    }

}

我找到最后人也呆了,人直接蒙了。

后来看出来了

大家知悉看这一句


    @RabbitListener(queues = "simple.queue")

我把 "? . " 写为 ”? ,?“了

代码仔细,改错两行泪?

文章来源:https://blog.csdn.net/qq_53573029/article/details/135515531
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。