获得以下异常的原因是什么:
org.springframework.amqp.UncategorizedAmqpException
org.springframework.amqp.UncategorizedAmqpException: java.lang.IllegalStateException: Invalid configuration: 'routingKey' must be non-null. at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:76) at org.springframework.amqp.rabbit.connection.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:110)
Note: Queue, ROuting key, exchange, all are defined in yml file. The error goes away on restarting a server.
可以做些什么来避免这种异常。
根据您的堆栈跟踪,看起来您使用RabbitTemplate
为null
配置routingKey
:
public Publish(int ticket, String exchange, String routingKey, boolean mandatory, boolean immediate) {
if (exchange == null)
throw new IllegalStateException("Invalid configuration: 'exchange' must be non-null.");
if (routingKey == null)
throw new IllegalStateException("Invalid configuration: 'routingKey' must be non-null.");
不确定这是怎么可能的,所以我们需要一个简单的项目来玩。任何方式都可能与您的配置有些奇怪......