java - 引起:com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:
问题描述
我有一个关于 RabitMQ JAVA Queue 的错误。当我尝试运行消费者客户端时,他向我抛出了这个异常。
Exception in thread "main" java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
at com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1107)
at com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1075)
at com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1059)
at rabbit.consumer.ConsumerDVD.main(ConsumerDVD.java:52)
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no queue 'hello' in vhost '/', class-id=60, method-id=20)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:361)
at com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1105)
... 3 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no queue 'hello' in vhost '/', class-id=60, method-id=20)
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:484)
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:321)
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:554)
at java.lang.Thread.run(Thread.java:748)
我的部分代码:
public class ConsumerDVD {
private final static String QUEUE_NAME = "hello";
private static Writer writer;
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
throws IOException {
DVD dvd = DVD.fromBytes(body);
System.out.println(" [x] Received '" + dvd.toString() + "'");
mailService.sendMail("cata1096@yahoo.com","Dvd has been added -- Rabbit!", dvd.toString());
writeToFile(dvd);
}
};
channel.basicConsume(QUEUE_NAME, true, consumer);
解决方案
推荐阅读
- amazon-web-services - 恼人的!CloudWatch 仪表板每隔几分钟就会转到主页
- spring-boot - SpringBoot 从类路径加载配置文件属性
- excel - 处理 Excel VBA 中的错误“13”(西班牙语中的变量和文本)
- python - 在 Python 中以日期格式删除时间
- java - Java 将 CSV 转换为 XLSX
- javascript - JS:从字符串中获取值
- python-3.x - pathlib match() 找不到相同模式的文件,可以通过 glob() 找到
- java - 当 a、b 或 c <= 1000 时,更快地找到所有毕达哥拉斯四元组
- mysql - 部分匹配号字段
- javascript - 如何以编程方式更新 shadow dom 内的输入?