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/21 17:46:12 UTC

svn commit: r806607 - /incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/ActiveMQMessageSender.java

Author: cwiklik
Date: Fri Aug 21 15:46:12 2009
New Revision: 806607

URL: http://svn.apache.org/viewvc?rev=806607&view=rev
Log:
UIMA-1477 added more logging to debug CPC problem

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

Modified: incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/ActiveMQMessageSender.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/ActiveMQMessageSender.java?rev=806607&r1=806606&r2=806607&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/ActiveMQMessageSender.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/ActiveMQMessageSender.java Fri Aug 21 15:46:12 2009
@@ -29,7 +29,11 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
+import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.adapter.jms.JmsConstants;
+import org.apache.uima.util.Level;
 
 /**
  * Initializes JMS session and creates JMS MessageProducer to be used for
@@ -41,6 +45,7 @@
  * 
  */
 public class ActiveMQMessageSender extends BaseMessageSender {
+  private static final Class CLASS_NAME = ActiveMQMessageSender.class;
 
 	private Connection connection = null;
 	private Session session = null;
@@ -67,10 +72,36 @@
 		producerMap.put(destination, mProducer);
 		return mProducer;
 	}
+	private String getBrokerURL() {
+    try {
+      return ((ActiveMQConnection)connection).getBrokerInfo().getBrokerURL();
+    } catch( Exception ex) { /* handle silently. */}
+    return "";
+	}
 	private void createSession() throws Exception {
-		if ( session == null )	{
-			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-		}
+	  String broker = getBrokerURL();
+	  try {
+	    if ( session == null )  {
+	      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+	    }
+	  } catch( JMSException e) {
+	    if ( UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO) ) {
+	      UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "createSession", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_client_failed_creating_session_INFO", new Object[] {destinationName, broker});
+	    }
+	    if ( connection == null ) {
+	      System.out.println("UIMA AS Client Shared Connection Is Not Initialized");
+	      if ( UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO) ) {
+	        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "createSession", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_client_connection_not_ready_INFO", new Object[] {broker});
+	      }
+	    } else if ( ((ActiveMQConnection)connection).isClosed() || ((ActiveMQConnection)connection).isClosing()) {
+	      if ( UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO) ) {
+	        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "createSession", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_client_connection_closed_INFO", new Object[] {destinationName, broker});
+	      }
+	    }
+	    throw e;
+	  } catch( Exception e) {
+	    throw e;
+	  }
 	}
 	/**
 	 * Creates a jms session object used to instantiate message producer