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/08/11 22:23:24 UTC

svn commit: r803280 - /incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsEndpointConnection_impl.java

Author: cwiklik
Date: Tue Aug 11 20:23:23 2009
New Revision: 803280

URL: http://svn.apache.org/viewvc?rev=803280&view=rev
Log:
UIMA-1439 Modified isOpen() to better detect dead connection to a broker

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

Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsEndpointConnection_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsEndpointConnection_impl.java?rev=803280&r1=803279&r2=803280&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsEndpointConnection_impl.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsEndpointConnection_impl.java Tue Aug 11 20:23:23 2009
@@ -125,7 +125,12 @@
 
 	public boolean isOpen()
 	{
-		if (producerSession == null)
+		if ( failed ||
+		        producerSession == null || 
+		          brokerDestinations.getConnection() == null || 
+		            ((ActiveMQConnection)brokerDestinations.getConnection()).isClosed() ||
+		              ((ActiveMQConnection)brokerDestinations.getConnection()).isClosing() ||
+		                 ((ActiveMQConnection)brokerDestinations.getConnection()).isTransportFailed())
 		{
 			return false;
 		}
@@ -159,7 +164,7 @@
 	                new Object[] { anEndpointName, brokerUri });
       }
       
-      if ( brokerDestinations.getConnection() == null ) {
+      if ( !isOpen() ) {  
         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUri);
         factory.setDispatchAsync(true);
         factory.setUseAsyncSend(true);
@@ -203,7 +208,7 @@
 			producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
 			// Since the connection is shared, start it only once 
 			if ( !((ActiveMQConnection)brokerDestinations.getConnection()).isStarted() ) {
-	      brokerDestinations.getConnection().start();
+			  brokerDestinations.getConnection().start();
 			}
 			if ( controller != null )
 			{
@@ -216,6 +221,7 @@
           }
         }
 			}
+			failed = false;
 		}
 		catch ( Exception e)
 		{