通道关闭:通道错误

时间:2016-01-04 12:38:04

标签: spring rabbitmq amqp spring-rabbit spring-rabbitmq

有时我在我的日志文件中找到了以下条目。我不知道问题是什么。我的猜测是设置一个较低的请求心跳。还有其他想法吗? 此外,我有一个情绪,在兔子重新启动后,我的服务器无法在兔子恢复后重新建立服务。我必须重启我的服务器,才能重新连接。

[AMQP Connection xxx:5672] [ERROR] org.springframework.amqp.rabbit.connection.CachingConnectionFactory - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'xxxx' in vhost 'aaa', class-id=60, method-id=40)

交换和队列不是自动删除?

公共类AmqpConfiguration {

@Autowired
private ConnectionFactory connectionFactory;  

@Bean
public Queue receiverQueue() {
    return new Queue("receiverQueue", true, false, false, getDeadLetterExchangeArgs());
}

@Bean
public FanoutExchange senderExchange() {
    return new FanoutExchange("xxxx");
}

@Bean
public Queue deadLetterQueue() {
    return new Queue("deadLetterQueue");
}

@Bean
public FanoutExchange exchangeDeadLetter() {
    return new FanoutExchange("deadLetter.exchange");
}


@Bean
public Binding bindDeadLetterQueueToExchange() {
    return BindingBuilder.bind(deadLetterQueue()).to(exchangeDeadLetter());
}


@Bean
public Binding bindSenderExchangeToQueue() {
    return BindingBuilder.bind(receiverQueue()).to(senderExchange());
}

@Bean(name = { "listenerContainerFactory" })
public SimpleRabbitListenerContainerFactory listenerContainerFactory() {
    final SimpleRabbitListenerContainerFactory containerFactory = new SimpleRabbitListenerContainerFactory();
    containerFactory.setDefaultRequeueRejected(false);
    containerFactory.setConnectionFactory(connectionFactory);

    // TODO: set heartbeat

    return containerFactory;
}

private Map<String, Object> getDeadLetterExchangeArgs() {
    final Map<String, Object> args = new HashMap<String, Object>();
    args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
    return args;
}

}

干杯,

丹尼斯

1 个答案:

答案 0 :(得分:0)

  

没有交换&#39; xxxx&#39;在vhost&#39; aaa&#39;

我在您显示的配置中看不到交换xxxx

也许你有一些伪造的代码发送到那个交易所?

修改

如果它是启动应用,并且您正在使用amqp启动器,则兔子自动配置将为您创建管理员。重新启动服务器后,您应该看到这些消息(如果启用DEBUG日志记录)...

09:43:03.450 [SimpleAsyncTaskExecutor-9] INFO  o.s.a.r.c.CachingConnectionFactory - Created new connection: SimpleConnection@b6e2e2c [delegate=amqp://guest@127.0.0.1:5672/]
09:43:03.451 [SimpleAsyncTaskExecutor-9] DEBUG o.s.amqp.rabbit.core.RabbitAdmin - Initializing declarations
09:43:03.451 [SimpleAsyncTaskExecutor-9] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'senderExchange'
09:43:03.451 [SimpleAsyncTaskExecutor-9] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'receiverQueue'
09:43:03.451 [SimpleAsyncTaskExecutor-9] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'bindSenderExchangeToQueue'
09:43:03.451 [SimpleAsyncTaskExecutor-9] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry'
09:43:03.452 [SimpleAsyncTaskExecutor-9] DEBUG o.s.a.r.c.CachingConnectionFactory - Creating cached Rabbit Channel from AMQChannel(amqp://guest@127.0.0.1:5672/,1)
09:43:03.452 [SimpleAsyncTaskExecutor-9] DEBUG o.s.amqp.rabbit.core.RabbitTemplate - Executing callback on RabbitMQ Channel: Cached Rabbit Channel: AMQChannel(amqp://guest@127.0.0.1:5672/,1)
09:43:03.452 [SimpleAsyncTaskExecutor-9] DEBUG o.s.amqp.rabbit.core.RabbitAdmin - declaring Exchange 'xxxx'
09:43:03.452 [SimpleAsyncTaskExecutor-9] DEBUG o.s.amqp.rabbit.core.RabbitAdmin - declaring Queue 'receiverQueue'
09:43:03.453 [SimpleAsyncTaskExecutor-9] DEBUG o.s.amqp.rabbit.core.RabbitAdmin - Binding destination [receiverQueue (QUEUE)] to exchange [xxxx] with routing key []
09:43:03.453 [SimpleAsyncTaskExecutor-9] DEBUG o.s.amqp.rabbit.core.RabbitAdmin - Declarations finished

管理员注册为连接工厂的监听器,并在建立连接时始终声明队列/交换/绑定。

您有多个连接工厂/虚拟主机吗?如果是这样,您需要每个管理员 - 请参阅section on conditional declaration