Channel shutdown: channel error

MelleD picture MelleD · Jan 4, 2016 · Viewed 11.2k times · Source

sometimes i found follow entry in my log file. I have no idea what the problem is. My guess is to set a lower request heartbeat. Any other ideas? Additionally i had the situtation that after a rabbit restart my server was not able to reestablish the service after the rabbit was back. I have to restart my server, that a reconnection is possible.

[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)

The exchange and queue are not auto-delete?

public class 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;
}

}

Cheers,

Dennis

Answer

Gary Russell picture Gary Russell · Jan 4, 2016

no exchange 'xxxx' in vhost 'aaa'

I don't see an exchange xxxx in the configuration you showed.

Perhaps you have some bogus code sending to that exchange?

EDIT

If it's a boot app, and you are using the amqp starter, the rabbit autoconfiguration will create an admin for you. After restarting the server, you should see messages like these (if you enable DEBUG logging)...

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

The admin is registered as a listener to the connection factory and always declares the queues/exchanges/bindings when the connection is established.

Do you have multiple connection factories/vhosts? If so, you need an admin for each - see the section on conditional declaration.