我正在尝试创建一个Spring Boot端点,该端点使用来自队列的消息,这是我的代码:
@PostMapping("test")
@RabbitListener(queues = "test-queue")
public String test(@RequestBody String body, String in) {
ConnectionFactory connectionFactory = new CachingConnectionFactory();
AmqpAdmin admin = new RabbitAdmin(connectionFactory);
admin.declareQueue(new Queue("test-queue"));
return in;
}
然而,当我启动Spring Boot应用程序时,我收到一个非常奇怪的警告:
2022-05-20 14:58:40.713 WARN 78294 --- [92.168.1.3:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
2022-05-20 14:58:40.719 WARN 78294 --- [e01:f475%4:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
2022-05-20 14:58:40.726 WARN 78294 --- [e01:f474%5:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
2022-05-20 14:58:40.730 WARN 78294 --- [dc:4823%12:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
2022-05-20 14:59:40.769 WARN 78294 --- [80:5beb%14:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
我该如何解决这个问题?
1条答案
按热度按时间xxhby3vn1#
这个问题可能是因为您监听了错误的端口或者防火墙阻止了您的连接。请确保您的RabbitMQ代理已启动并监听了端口5672,并且防火墙允许tcp连接到该端口。