引起原因:com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:

时间:2018-12-02 14:38:00

标签: java rabbitmq queue

关于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)

原因:com.rabbitmq.client.ShutdownSignalException:频道错误;协议方法:#method(回复代码= 404,回复文本= NOT_FOUND-虚拟主机'/'中没有队列“你好”,类ID = 60,方法ID = 20)     在com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)     在com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)     在com.rabbitmq.client.impl.AMQChannel $ BlockingRpcContinuation.getReply(AMQChannel.java:361)     在com.rabbitmq.client.impl.ChannelN.basicConsume(ChannelN.java:1105)     ...另外3个 引起原因:com.rabbitmq.client.ShutdownSignalException:通道错误;协议方法:#method(回复代码= 404,回复文本= NOT_FOUND-虚拟主机'/'中没有队列“你好”,类ID = 60,方法ID = 20)     在com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:484)     在com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:321)     在com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)     在com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)     在com.rabbitmq.client.impl.AMQConnection $ MainLoop.run(AMQConnection.java:554)     在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);

0 个答案:

没有答案