通道关闭:通道错误

问题描述 投票:0回答:1

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

[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;
}

}

干杯,

丹尼斯

spring rabbitmq amqp spring-rabbit
1个回答
0
投票

虚拟主机“aaa”中没有交换“xxxx”

我在您展示的配置中没有看到交换

xxxx

也许您有一些虚假代码发送到该交易所?

编辑

如果它是一个启动应用程序,并且您正在使用 amqp 启动器,rabbit 自动配置将为您创建一个管理员。重新启动服务器后,您应该看到类似这样的消息(如果启用调试日志记录)...

09:43:03.450 [SimpleAsyncTaskExecutor-9] INFO  o.s.a.r.c.CachingConnectionFactory - Created new connection: SimpleConnection@b6e2e2c [delegate=amqp://[email protected]: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://[email protected]: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://[email protected]: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

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

您有多个连接工厂/虚拟主机吗?如果是这样,您需要为每个管理员设置一个管理员 - 请参阅有关条件声明的部分

© www.soinside.com 2019 - 2024. All rights reserved.