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 2013/06/03 21:56:03 UTC

svn commit: r1489134 - /uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java

Author: cwiklik
Date: Mon Jun  3 19:56:03 2013
New Revision: 1489134

URL: http://svn.apache.org/r1489134
Log:
UIMA-2776 Make Session timer a global so that it can be stopped on service shutdown

Modified:
    uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java

Modified: uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java?rev=1489134&r1=1489133&r2=1489134&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java (original)
+++ uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java Mon Jun  3 19:56:03 2013
@@ -1854,8 +1854,6 @@ public class JmsOutputChannel implements
   protected class ConnectionTimer {
     private final Class CLASS_NAME = ConnectionTimer.class;
 
-    private Timer timer;
-
     private long inactivityTimeout;
 
     private AnalysisEngineController controller;
@@ -1866,6 +1864,8 @@ public class JmsOutputChannel implements
 
     private String componentName = "";
 
+    private ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
+    
     public ConnectionTimer(BrokerConnectionEntry aBrokerDestinations) {
       brokerDestinations = aBrokerDestinations;
     }
@@ -1885,6 +1885,11 @@ public class JmsOutputChannel implements
       connectionCreationTimestamp = aConnectionCreationTimestamp;
     }
 
+    public void stopSessionReaperTimer() {
+      if ( scheduler != null ) {
+        scheduler.shutdownNow();
+      }
+    }
     /**
      * Schedules regular cleanup of JMS sessions. A session is cleaned up (closed) if it has not
      * been used in an interval defined by value in inactivityTimeout.
@@ -1892,7 +1897,7 @@ public class JmsOutputChannel implements
      * @param aComponentName
      */
     public synchronized void startSessionReaperTimer( String aComponentName) {
-        ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
+        
         //	Fire the runnable at fixed intervals equal to inactivityTimeout value
         scheduler.scheduleAtFixedRate(new Runnable(){
             public void run() {
@@ -1968,15 +1973,14 @@ public class JmsOutputChannel implements
         
       }
     private void cancelTimer() {
-      if (timer != null) {
-        timer.cancel();
-        timer.purge();
+      
+      if ( scheduler != null ) {
+        scheduler.shutdownNow();
       }
     }
 
     public synchronized void stopTimer() {
       cancelTimer();
-      timer = null;
     }
   }