SimpleMessageListenerContainer

SimpleMessageListenerContainer

当某个事件到达时,我使用rabbitmq listner停止container.stop();,并在完成所需的作业后,使用container.start()重新启动它,但是当一个新事件到达时,出现以下错误:

Exception in thread "SimpleAsyncTaskExecutor-1" 2016-04-22T16:20:53.646  WARN 15336 --- [cTaskExecutor-1] o.s.a.r.l.SimpleMessageListenerContainer : Consumer raised exception, processing can restart if the connection factory supports it
java.lang.NullPointerException: null
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.isActive(SimpleMessageListenerContainer.java:756) ~[spring-rabbit-1.4.3.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$600(SimpleMessageListenerContainer.java:82) ~[spring-rabbit-1.4.3.RELEASE.jar:na]
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1100) ~[spring-rabbit-1.4.3.RELEASE.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]

最佳答案

它实际上是无害(但很恐怖)的日志消息,但它是fixed in 1.5.3

this answer中所述:


通常最好将容器停在单独的线程上。


因为直到侦听器退出,容器才能完全停止。

10-07 13:21