2015-05-08 44 views
3

當消費者在SimpleMessageListenerContainershutdownTimeout之後沒有完成執行時,我的Spring應用程序被掛起。帶RabbitMQ的spring-amqp沒有正常關機

監聽器:

public class LongRunningMessageListener implements MessageListener { 

    @Override 
    public void onMessage(Message message) { 
     System.out.println("Got " + new String(message.getBody())); 
     try { 
      Thread.sleep(5000L); 
     } catch (InterruptedException e) { 
      System.out.println("Interrupted"); 
      Thread.currentThread().interrupt(); 
     } 
     System.out.println("Finished execution"); 
    } 
} 

配置:

@Configuration 
public class Config { 

    @Bean 
    public MessageListenerContainer messageListenerContainer() { 
     SimpleMessageListenerContainer messageListenerContainer = new SimpleMessageListenerContainer(connectionFactory()); 
     messageListenerContainer.setQueueNames("myqueue"); 
     messageListenerContainer.setMessageListener(new LongRunningMessageListener()); 
     messageListenerContainer.setShutdownTimeout(1000); 
     return messageListenerContainer; 
    } 

    @Bean 
    public ConnectionFactory connectionFactory() { 
     return new CachingConnectionFactory("localhost"); 
    } 
} 

主營:

public static void main(String[] args) throws InterruptedException { 
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(Config.class); 
    Thread.sleep(1000L); 
    applicationContext.close(); 
} 

輸出:

мая 08, 2015 3:43:21 PM org.springframework.context.annotation.AnnotationConfigApplicationContext prepareRefresh 
INFO: Refreshing org.spring[email protected]1a86f2f1: startup date [Fri May 08 15:43:21 MSK 2015]; root of context hierarchy 
мая 08, 2015 3:43:22 PM org.springframework.context.support.DefaultLifecycleProcessor start 
INFO: Starting beans in phase 2147483647 
мая 08, 2015 3:43:22 PM org.springframework.amqp.rabbit.connection.CachingConnectionFactory createBareConnection 
INFO: Created new connection: [email protected] [delegate=amqp://[email protected]:5672/] 
Got foo1 
мая 08, 2015 3:43:23 PM org.springframework.context.annotation.AnnotationConfigApplicationContext doClose 
INFO: Closing org.spring[email protected]1a86f2f1: startup date [Fri May 08 15:43:21 MSK 2015]; root of context hierarchy 
мая 08, 2015 3:43:23 PM org.springframework.context.support.DefaultLifecycleProcessor stop 
INFO: Stopping beans in phase 2147483647 
мая 08, 2015 3:43:23 PM org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer doShutdown 
INFO: Waiting for workers to finish. 
мая 08, 2015 3:43:24 PM org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer doShutdown 
INFO: Workers not finished. Forcing connections to close. 
Finished execution 
мая 08, 2015 3:43:27 PM org.springframework.amqp.rabbit.connection.CachingConnectionFactory createBareConnection 
INFO: Created new connection: [email protected] [delegate=amqp://[email protected]:5672/] 
мая 08, 2015 3:43:27 PM org.springframework.amqp.rabbit.connection.CachingConnectionFactory shutdownCompleted 
SEVERE: Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 1, class-id=60, method-id=80) 

之後,該應用程序無限工作。

工作線程:

Live threads: 14 
Daemon threads: 10 

非守護線程:

"pool-1-thread-10" #22 prio=5 os_prio=31 tid=0x00007fd48c93c800 nid=0x5a07 waiting on condition [0x0000000129eb3000] 
    java.lang.Thread.State: WAITING (parking) 
    at sun.misc.Unsafe.park(Native Method) 
    - parking to wait for <0x0000000796333168> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) 
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) 
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) 
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) 
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

    Locked ownable synchronizers: 
    - None 

"pool-1-thread-9" #21 prio=5 os_prio=31 tid=0x00007fd48b9d8000 nid=0x540b waiting on condition [0x0000000129db0000] 
    java.lang.Thread.State: TIMED_WAITING (parking) 
    at sun.misc.Unsafe.park(Native Method) 
    - parking to wait for <0x000000079633dfb0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) 
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) 
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) 
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) 
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

    Locked ownable synchronizers: 
    - None 

"AMQP Connection 127.0.0.1:5672" #20 prio=5 os_prio=31 tid=0x00007fd48d186000 nid=0x530b runnable [0x0000000129cad000] 
    java.lang.Thread.State: RUNNABLE 
    at java.net.SocketInputStream.socketRead0(Native Method) 
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) 
    at java.net.SocketInputStream.read(SocketInputStream.java:170) 
    at java.net.SocketInputStream.read(SocketInputStream.java:141) 
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) 
    at java.io.BufferedInputStream.read(BufferedInputStream.java:265) 
    - locked <0x000000079632e8f0> (a java.io.BufferedInputStream) 
    at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) 
    at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95) 
    at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:139) 
    - locked <0x000000079632e8d0> (a java.io.DataInputStream) 
    at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:534) 
    at java.lang.Thread.run(Thread.java:745) 

    Locked ownable synchronizers: 
    - None 

"DestroyJavaVM" #19 prio=5 os_prio=31 tid=0x00007fd48d002000 nid=0x1303 waiting on condition [0x0000000000000000] 
    java.lang.Thread.State: RUNNABLE 

    Locked ownable synchronizers: 
    - None 

一切都很好,如果我增加shutdownTimeout,但超時行爲看起來像一個錯誤。

春季版本:

spring-amqp 1.4.5.RELEASE 
spring-rabbit 1.4.5.RELEASE 
spring-context 4.1.5.RELEASE 

更新: 我已經Log調用代替了System.out.println調用和日誌記錄配置log4j的。圖案:%r [%t] %-5p %c{1} - %m%n

輸出:

0 [main] DEBUG StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence 
3 [main] DEBUG StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence 
4 [main] DEBUG StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment] 
130 [main] INFO AnnotationConfigApplicationContext - Refreshing org.spring[email protected]73a8dfcc: startup date [Fri May 08 17:07:06 MSK 2015]; root of context hierarchy 
132 [main] DEBUG AnnotationConfigApplicationContext - Bean factory for org.spring[email protected]73a8dfcc: org.s[email protected]1593948d: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,config]; root of factory hierarchy 
178 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' 
179 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' 
232 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' to allow for resolving potential circular references 
235 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' 
288 [main] DEBUG ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method Config.messageListenerContainer() 
288 [main] DEBUG ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method Config.connectionFactory() 
431 [main] DEBUG ConfigurationClassEnhancer - Successfully enhanced Config; enhanced class name is: Config$$EnhancerBySpringCGLIB$$b6627e0a 
432 [main] DEBUG ConfigurationClassPostProcessor - Replacing bean definition 'config' existing class name 'Config' with enhanced class name 'Config$$EnhancerBySpringCGLIB$$b6627e0a' 
436 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' 
436 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' 
438 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' to allow for resolving potential circular references 
438 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' 
438 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' 
438 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' 
439 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' to allow for resolving potential circular references 
439 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' 
439 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor' 
439 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor' 
445 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor' to allow for resolving potential circular references 
445 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor' 
445 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor' 
445 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor' 
445 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor' to allow for resolving potential circular references 
446 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor' 
446 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor' 
446 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor' 
446 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor' to allow for resolving potential circular references 
446 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor' 
450 [main] DEBUG AnnotationConfigApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [[email protected]15d9] 
454 [main] DEBUG AnnotationConfigApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.[email protected]b3d7190] 
461 [main] DEBUG DefaultListableBeanFactory - Pre-instantiating singletons in org.s[email protected]1593948d: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,config,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,messageListenerContainer,connectionFactory]; root of factory hierarchy 
461 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' 
462 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' 
462 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' 
462 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor' 
462 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'config' 
463 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'config' 
468 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'config' to allow for resolving potential circular references 
494 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'config' 
494 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor' 
494 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor' 
494 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'messageListenerContainer' 
495 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'messageListenerContainer' 
497 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'config' 
551 [main] DEBUG DefaultListableBeanFactory - Creating shared instance of singleton bean 'connectionFactory' 
551 [main] DEBUG DefaultListableBeanFactory - Creating instance of bean 'connectionFactory' 
552 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'config' 
595 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'connectionFactory' to allow for resolving potential circular references 
609 [main] DEBUG DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'connectionFactory' 
609 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'connectionFactory' 
638 [main] DEBUG DefaultListableBeanFactory - Eagerly caching bean 'messageListenerContainer' to allow for resolving potential circular references 
707 [main] DEBUG DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'messageListenerContainer' 
708 [main] DEBUG SimpleMessageListenerContainer - No global properties bean 
708 [main] DEBUG DefaultListableBeanFactory - Finished creating instance of bean 'messageListenerContainer' 
708 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'connectionFactory' 
710 [main] DEBUG AnnotationConfigApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [[email protected]2fe6d] 
710 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'messageListenerContainer' 
710 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
716 [main] INFO DefaultLifecycleProcessor - Starting beans in phase 2147483647 
716 [main] DEBUG DefaultLifecycleProcessor - Starting bean 'messageListenerContainer' of type [class org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer] 
716 [main] DEBUG SimpleMessageListenerContainer - No global properties bean 
716 [main] DEBUG SimpleMessageListenerContainer - Starting Rabbit listener container. 
767 [SimpleAsyncTaskExecutor-1] DEBUG BlockingQueueConsumer - Starting consumer Consumer: tags=[{}], channel=null, acknowledgeMode=AUTO local queue size=0 
852 [SimpleAsyncTaskExecutor-1] INFO CachingConnectionFactory - Created new connection: [email protected] [delegate=amqp://[email protected]:5672/] 
869 [SimpleAsyncTaskExecutor-1] DEBUG CachingConnectionFactory - Creating cached Rabbit Channel from AMQChannel(amqp://[email protected]:5672/,1) 
911 [pool-1-thread-3] DEBUG BlockingQueueConsumer - ConsumeOK : Consumer: tags=[{}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0 
914 [pool-1-thread-4] DEBUG BlockingQueueConsumer - Storing delivery for Consumer: tags=[{}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0 
915 [SimpleAsyncTaskExecutor-1] DEBUG BlockingQueueConsumer - Started on queue 'myqueue' with tag amq.ctag-KkQJOq3Z0r8Uc0JwcKdGxQ: Consumer: tags=[{amq.ctag-KkQJOq3Z0r8Uc0JwcKdGxQ=myqueue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=1 
916 [SimpleAsyncTaskExecutor-1] DEBUG BlockingQueueConsumer - Retrieving delivery for Consumer: tags=[{amq.ctag-KkQJOq3Z0r8Uc0JwcKdGxQ=myqueue}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=1 
920 [SimpleAsyncTaskExecutor-1] DEBUG BlockingQueueConsumer - Received message: (Body:'foo5'MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, appId=null, clusterId=null, type=null, correlationId=null, replyTo=null, contentType=text/plain, contentEncoding=UTF-8, contentLength=0, deliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=true, receivedExchange=, receivedRoutingKey=myqueue, deliveryTag=1, messageCount=0]) 
921 [SimpleAsyncTaskExecutor-1] INFO LongRunningMessageListener - Got foo5 
921 [main] DEBUG DefaultLifecycleProcessor - Successfully started bean 'messageListenerContainer' 
931 [main] DEBUG PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties] 
932 [main] DEBUG PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment] 
933 [main] DEBUG PropertySourcesPropertyResolver - Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null] 
1938 [main] INFO AnnotationConfigApplicationContext - Closing org.spring[email protected]73a8dfcc: startup date [Fri May 08 17:07:06 MSK 2015]; root of context hierarchy 
1938 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'messageListenerContainer' 
1938 [main] DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
1939 [main] INFO DefaultLifecycleProcessor - Stopping beans in phase 2147483647 
1939 [main] DEBUG DefaultLifecycleProcessor - Asking bean 'messageListenerContainer' of type [class org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer] to stop 
1939 [main] DEBUG SimpleMessageListenerContainer - Shutting down Rabbit listener container 
1941 [main] INFO SimpleMessageListenerContainer - Waiting for workers to finish. 
1941 [pool-1-thread-5] DEBUG BlockingQueueConsumer - Received cancellation notice for tag amq.ctag-KkQJOq3Z0r8Uc0JwcKdGxQ; Consumer: tags=[{}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0 
2946 [main] INFO SimpleMessageListenerContainer - Workers not finished. Forcing connections to close. 
2946 [main] DEBUG DefaultLifecycleProcessor - Bean 'messageListenerContainer' completed its stop procedure 
2946 [main] DEBUG DefaultListableBeanFactory - Destroying singletons in org.s[email protected]1593948d: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,config,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,messageListenerContainer,connectionFactory]; root of factory hierarchy 
2946 [main] DEBUG DisposableBeanAdapter - Invoking destroy() on bean with name 'messageListenerContainer' 
2946 [main] DEBUG SimpleMessageListenerContainer - Shutting down Rabbit listener container 
2946 [main] DEBUG DisposableBeanAdapter - Invoking destroy() on bean with name 'connectionFactory' 
5923 [SimpleAsyncTaskExecutor-1] INFO LongRunningMessageListener - Finished execution 
5927 [SimpleAsyncTaskExecutor-1] INFO CachingConnectionFactory - Created new connection: [email protected] [delegate=amqp://[email protected]:5672/] 
5928 [SimpleAsyncTaskExecutor-1] DEBUG BlockingQueueConsumer - Retrieving delivery for Consumer: tags=[{}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0 
5929 [AMQP Connection 127.0.0.1:5672] ERROR CachingConnectionFactory - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 1, class-id=60, method-id=80) 
6932 [SimpleAsyncTaskExecutor-1] DEBUG SimpleMessageListenerContainer - Cancelling Consumer: tags=[{}], channel=Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1), acknowledgeMode=AUTO local queue size=0 
6933 [SimpleAsyncTaskExecutor-1] DEBUG BlockingQueueConsumer - Closing Rabbit Channel: Cached Rabbit Channel: AMQChannel(amqp://[email protected]:5672/,1) 
6933 [SimpleAsyncTaskExecutor-1] DEBUG CachingConnectionFactory - Closing cached Channel: AMQChannel(amqp://[email protected]:5672/,1) 
+0

請重新發布日誌,包括線程名稱(例如log4j中的'%t') –

+0

@GaryRussell,我已經添加了log4j輸出。 –

+0

謝謝;所以你只是說,如果一個監聽器比'shutdownTimeout'花費的時間更長,容器不能正常停止? –

回答

0

關於你提到的關於這個問題的意見(響應@阿爾喬姆的變通)...

我已經試過這種解決方案也是如此。它適用於這種簡單情況(Thread.sleep()),但在偵聽器正在做長時間等待IO的「真實」工作時不起作用。

如果用戶代碼處於不可中斷狀態(如等待套接字I/O)時,框架無能爲力。您需要以某種方式關閉套接字。

+0

這是確定的,如果應用程序不會死,而工人不間斷狀態,但一段時間後,他們將成爲中斷(剛過消息處理)。但是,由於框架的內部非守護進程正在運行線程,應用程序也不會完成它的執行。 順便說一句System.exit()是適合的解決方法。 –

+1

正確的JIRA修復將糾正;我只是說我們不能對不間斷代碼做任何事情。 –