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 2011/02/08 18:48:29 UTC
svn commit: r1068493 -
/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsInputChannel.java
Author: cwiklik
Date: Tue Feb 8 17:48:29 2011
New Revision: 1068493
URL: http://svn.apache.org/viewvc?rev=1068493&view=rev
Log:
UIMA-2038 Modified to close shared connection to a broker when stopping the last listener
Modified:
uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsInputChannel.java
Modified: uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsInputChannel.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsInputChannel.java?rev=1068493&r1=1068492&r2=1068493&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsInputChannel.java (original)
+++ uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsInputChannel.java Tue Feb 8 17:48:29 2011
@@ -886,14 +886,31 @@ public class JmsInputChannel implements
remoteJMXServer = null;
}
}
-
+ public void setTerminating() {
+ if ( listenerContainerList.size() > 0 ) {
+ // set a global static flag to stop spring's from automatic recovery on lost connection
+ // This method should be called when a service is shutting down
+ ((UimaDefaultMessageListenerContainer)listenerContainerList.get(0)).setTerminating();
+ }
+ }
+ public void terminate() {
+ try {
+ if ( listenerContainerList.size() > 0 ) {
+ ((UimaDefaultMessageListenerContainer)listenerContainerList.get(0)).closeConnection();
+ }
+ } catch( Exception e) {
+ UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
+ "terminate", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
+ "UIMAEE_exception__WARNING", e);
+ }
+
+ }
public synchronized void stop(int channelsToClose) throws Exception {
-
List<UimaDefaultMessageListenerContainer> listenersToRemove = new ArrayList<UimaDefaultMessageListenerContainer>();
for (Object listenerObject : listenerContainerList) {
final UimaDefaultMessageListenerContainer mL = (UimaDefaultMessageListenerContainer) listenerObject;
if (mL != null && mL.isRunning() && doCloseChannel(mL, channelsToClose)) {
- stopChannel(mL);
+ stopChannel(mL);
// Just in case check if the container still in the list. If so, add it to
// another list that container listeners that have been stopped and need
// to be removed from the listenerContainerList. Removing the listener from
@@ -903,6 +920,14 @@ public class JmsInputChannel implements
// one element left. Process removal of listeners outside of the iterator
// loop
if (listenerContainerList.contains(mL)) {
+ // When last listener, close shared connection
+ if ( listenerContainerList.size() == 1 ) {
+ try {
+ mL.closeConnection();
+ } catch( Exception e) {
+ e.printStackTrace();
+ }
+ }
listenersToRemove.add(mL);
}
} else {
@@ -917,6 +942,10 @@ public class JmsInputChannel implements
}
// Remove listeners from the listenerContainerList
for (UimaDefaultMessageListenerContainer mL : listenersToRemove) {
+ if ( listenerContainerList.size() == 1 ) {
+ ((UimaDefaultMessageListenerContainer)listenerContainerList.get(0)).closeConnection();
+ }
+
listenerContainerList.remove(mL);
}
listenersToRemove.clear();