启动springboot报错channel error; protocol method #methodchannelclosereply-code=404 reply-text=NOT_FOUND - no queue messaged in vhost class-id=50 method-id=10
这个错误是因为在你的Spring Boot应用程序中尝试访问一个名为'messaged'的队列,但是在RabbitMQ服务器上找不到这个队列。
要解决这个问题,你需要确保在RabbitMQ服务器上创建了一个名为'messaged'的队列。你可以使用RabbitMQ的管理界面或者通过代码来创建队列。
如果你想通过代码来创建队列,可以在Spring Boot应用程序的配置文件中添加以下代码:
@Configuration
public class RabbitConfig {
@Autowired
private ConnectionFactory connectionFactory;
@Bean
public Queue messageQueue() {
return new Queue("messaged");
}
@Bean
public AmqpAdmin amqpAdmin() {
return new RabbitAdmin(connectionFactory);
}
@PostConstruct
public void init() {
amqpAdmin().declareQueue(messageQueue());
}
}
这个配置类会自动创建一个名为'messaged'的队列。在启动应用程序时,它会被自动声明并创建。
另外,确保你的应用程序的连接配置正确,包括RabbitMQ服务器的主机名、端口号、用户名和密码等。你可以在应用程序的配置文件中进行配置。
这样,当你启动Spring Boot应用程序时,就不会再报错找不到队列了
原文地址: http://www.cveoy.top/t/topic/iroD 著作权归作者所有。请勿转载和采集!