activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r663680 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Date Thu, 05 Jun 2008 17:57:55 GMT
Author: rajdavies
Date: Thu Jun  5 10:57:55 2008
New Revision: 663680

URL: http://svn.apache.org/viewvc?rev=663680&view=rev
Log:
Fix for https://issues.apache.org/activemq/browse/AMQ-1771

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=663680&r1=663679&r2=663680&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Thu Jun  5 10:57:55 2008
@@ -69,6 +69,7 @@
     private final Object reconnectMutex = new Object();
     private final Object backupMutex = new Object();
     private final Object sleepMutex = new Object();
+    private final Object listenerMutex = new Object();
     private final ConnectionStateTracker stateTracker = new ConnectionStateTracker();
     private final Map<Integer, Command> requestMap = new LinkedHashMap<Integer,
Command>();
 
@@ -564,7 +565,10 @@
     }
 
     public void setTransportListener(TransportListener commandListener) {
-        this.transportListener = commandListener;
+        synchronized(listenerMutex) {
+            this.transportListener = commandListener;
+            listenerMutex.notifyAll();
+        }
     }
 
     public <T> T narrow(Class<T> target) {
@@ -683,8 +687,21 @@
                             connectedTransport.set(t);
                             reconnectMutex.notifyAll();
                             connectFailures = 0;
+                         // Make sure on initial startup, that the transportListener 
+                         // has been initialized for this instance.
+                            synchronized(listenerMutex) {
+                                if (transportListener==null) {
+                                    try {
+                                        //if it isn't set after 2secs - it
+                                        //probably never will be
+                                    listenerMutex.wait(2000);
+                                    }catch(InterruptedException ex) {}
+                                }
+                            }
                             if (transportListener != null) {
                                 transportListener.transportResumed();
+                            }else {
+                                LOG.debug("transport resumed by transport listener not set");
                             }
                             if (firstConnection) {
                                 firstConnection=false;



Mime
View raw message