[jboss-cvs] JBoss Messaging SVN: r2950 - in trunk/src/main/org/jboss/messaging/core/impl: clusterconnection and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 3 08:20:43 EDT 2007
Author: timfox
Date: 2007-08-03 08:20:43 -0400 (Fri, 03 Aug 2007)
New Revision: 2950
Modified:
trunk/src/main/org/jboss/messaging/core/impl/DefaultClusterNotifier.java
trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java
Log:
Make sure notifications don't stall failover is they hang
Modified: trunk/src/main/org/jboss/messaging/core/impl/DefaultClusterNotifier.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/DefaultClusterNotifier.java 2007-08-03 11:41:33 UTC (rev 2949)
+++ trunk/src/main/org/jboss/messaging/core/impl/DefaultClusterNotifier.java 2007-08-03 12:20:43 UTC (rev 2950)
@@ -25,12 +25,16 @@
import java.util.Iterator;
import java.util.Set;
+import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.ClusterNotification;
import org.jboss.messaging.core.contract.ClusterNotificationListener;
import org.jboss.messaging.core.contract.ClusterNotifier;
import org.jboss.messaging.util.ConcurrentReaderHashSet;
+import EDU.oswego.cs.dl.util.concurrent.Callable;
+import EDU.oswego.cs.dl.util.concurrent.TimedCallable;
+
/**
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -41,6 +45,10 @@
*/
public class DefaultClusterNotifier implements ClusterNotifier
{
+ private static final Logger log = Logger.getLogger(DefaultClusterNotifier.class);
+
+ private static final long NOTIFICATION_TIMEOUT = 3000;
+
private Set listeners;
public DefaultClusterNotifier()
@@ -58,15 +66,32 @@
listeners.add(listener);
}
- public void sendNotification(ClusterNotification notification)
+ public void sendNotification(final ClusterNotification notification)
{
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
- ClusterNotificationListener listener = (ClusterNotificationListener)iter.next();
+ final ClusterNotificationListener listener = (ClusterNotificationListener)iter.next();
listener.notify(notification);
+
+ //We used a timed callable to make sure the call completes in a reasonable time
+ //This is because there have been issues with remoting hanging when closing message suckers
+ //and we don't want this to cause the entire failover process to hang
+
+ Callable callable = new Callable() { public Object call() { listener.notify(notification); return null; } };
+
+ Callable timedCallable = new TimedCallable(callable, NOTIFICATION_TIMEOUT);
+
+ try
+ {
+ timedCallable.call();
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to make notification", e);
+ }
}
}
Modified: trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java 2007-08-03 11:41:33 UTC (rev 2949)
+++ trunk/src/main/org/jboss/messaging/core/impl/clusterconnection/MessageSucker.java 2007-08-03 12:20:43 UTC (rev 2950)
@@ -231,8 +231,9 @@
consuming = false;
}
}
- catch (JMSException e)
+ catch (Exception e)
{
+ //We don't want to propagate up since that might cause failover to abort
log.error("Failed to change rate", e);
}
}
More information about the jboss-cvs-commits
mailing list