You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2009/06/24 21:25:58 UTC
svn commit: r788147 -
/incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java
Author: cwiklik
Date: Wed Jun 24 19:25:58 2009
New Revision: 788147
URL: http://svn.apache.org/viewvc?rev=788147&view=rev
Log:
UIMA-1402 Modified listener code to handle shutdown of ThreadPoolTaskExecutor better
Modified:
incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java
Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java?rev=788147&r1=788146&r2=788147&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java Wed Jun 24 19:25:58 2009
@@ -731,14 +731,21 @@
} catch( Exception e) {}
// If using non-default TaskExecutor, stop its threads
if ( taskExecutor != null && taskExecutor instanceof ThreadPoolTaskExecutor) {
- int activeThreadCount = ((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().getActiveCount();
- if ( activeThreadCount > 0 && !((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().isTerminated() ) {
- ((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().shutdown();
+ boolean doShutdownTaskExecutor = true;
+ while ( ((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().getActiveCount() > 0 &&
+ !((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().isTerminated() ) {
+ if ( doShutdownTaskExecutor ) {
+ ((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().shutdown();
+ doShutdownTaskExecutor = false; // shutdown once
+ }
try {
- ((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+ ((ThreadPoolTaskExecutor) taskExecutor).getThreadPoolExecutor().awaitTermination(100,TimeUnit.MILLISECONDS); ///Long.MAX_VALUE, TimeUnit.MILLISECONDS);
} catch ( Exception e){}
}
}
+ if ( taskExecutor != null ) {
+ System.out.println("+++++++++ Listener:"+getDestination()+" Controller ThreadPoolExecutor Stopped ...");
+ }
// Shutdown the listener
__listenerRef.shutdown();
if ( UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST) ) {