You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2015/02/06 22:27:02 UTC

svn commit: r1657967 - /uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/maintenance/MqHelper.java

Author: degenaro
Date: Fri Feb  6 21:27:02 2015
New Revision: 1657967

URL: http://svn.apache.org/r1657967
Log:
UIMA-4224 DUCC Orchestrator (OR) should reconnect to broker for JD queue clean-up

Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/maintenance/MqHelper.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/maintenance/MqHelper.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/maintenance/MqHelper.java?rev=1657967&r1=1657966&r2=1657967&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/maintenance/MqHelper.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/maintenance/MqHelper.java Fri Feb  6 21:27:02 2015
@@ -133,7 +133,7 @@ public class MqHelper {
 		return value;
 	}
 	
-	public void connect() throws IOException, MalformedObjectNameException, NullPointerException {
+	private void connect() throws IOException, MalformedObjectNameException, NullPointerException {
 		url = new JMXServiceURL(broker_url);
 		jmxc = JMXConnectorFactory.connect(url);
 		conn = jmxc.getMBeanServerConnection();
@@ -141,6 +141,24 @@ public class MqHelper {
 		mbean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(conn, activeMQ, BrokerViewMBean.class, true);
 	}
 	
+	private void reconnect() {
+		String location = "reconnect";
+		try {
+			if(jmxc != null) {
+				jmxc.close();
+			}
+		}
+		catch(Exception e) {
+			logger.error(location, jobid, e);
+		}
+		try {
+			connect();
+		}
+		catch(Exception e) {
+			logger.error(location, jobid, e);
+		}
+	}
+	
 	public String getBrokerUrl() {
 		return broker_url;
 	}
@@ -157,16 +175,30 @@ public class MqHelper {
 		return retVal;
 	}
 	
+	private ObjectName[] getQueues() {
+		ObjectName[] queues = null;
+		try {
+			queues = mbean.getQueues();
+		}
+		catch(Throwable t) {
+			reconnect();
+			queues = mbean.getQueues();
+		}
+		return queues;
+	}
+	
 	public ArrayList<String> getQueueList() {
 		ArrayList<String> qNames = new ArrayList<String>();
-		ObjectName[] queues = mbean.getQueues();
-		for( ObjectName queue : queues ) {
-			Hashtable<String, String> propertyTable = queue.getKeyPropertyList();
-			if(propertyTable != null) {
-				String type = propertyTable.get("Type");
-				String destination = propertyTable.get("Destination");
-				if(isEqual(type, "Queue")) {
-					qNames.add(destination);
+		ObjectName[] queues = getQueues();
+		if(queues != null) {
+			for( ObjectName queue : queues ) {
+				Hashtable<String, String> propertyTable = queue.getKeyPropertyList();
+				if(propertyTable != null) {
+					String type = propertyTable.get("Type");
+					String destination = propertyTable.get("Destination");
+					if(isEqual(type, "Queue")) {
+						qNames.add(destination);
+					}
 				}
 			}
 		}