[jboss-cvs] JBoss Messaging SVN: r4096 - in trunk: src/main/org/jboss/messaging/core/client/impl and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 22 10:27:13 EDT 2008


Author: jmesnil
Date: 2008-04-22 10:27:13 -0400 (Tue, 22 Apr 2008)
New Revision: 4096

Added:
   trunk/src/main/org/jboss/messaging/core/client/RemotingSessionListener.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/CleanUpNotifier.java
Removed:
   trunk/src/main/org/jboss/messaging/core/client/FailureListener.java
   trunk/src/main/org/jboss/messaging/core/remoting/RemotingException.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FailureNotifier.java
Modified:
   trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java
   trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnection.java
   trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnectionImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/RemotingService.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FilterChainSupport.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaKeepAliveFactory.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaService.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/FilterChainSupportTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/MinaKeepAliveFactoryTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java
Log:
* refactored code to handle remoting session clean up

Modified: trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -23,7 +23,7 @@
 
    void stop() throws MessagingException;
 
-   void setFailureListener(FailureListener listener) throws MessagingException;
+   void setRemotingSessionListener(RemotingSessionListener listener) throws MessagingException;
   
    void close() throws MessagingException;
    

Deleted: trunk/src/main/org/jboss/messaging/core/client/FailureListener.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/FailureListener.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/client/FailureListener.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -1,36 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core.client;
-
-import org.jboss.messaging.core.exception.MessagingException;
-
-/**
- * 
- * A FailureListener
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface FailureListener
-{
-   void onFailure(MessagingException me);
-}

Added: trunk/src/main/org/jboss/messaging/core/client/RemotingSessionListener.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/RemotingSessionListener.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/client/RemotingSessionListener.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.core.client;
+
+import org.jboss.messaging.core.exception.MessagingException;
+
+/**
+ * 
+ * A RemotingSessionListener
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ */
+public interface RemotingSessionListener
+{
+   /**
+    * This method is called when a remoting session is destroyed. It can be
+    * destroyed as part of its normal lifecycle after a clean close or if there
+    * has been a problem (e.g. network failure).
+    * 
+    * If the session was closed properly, <code>me</code> is <code>null</code>,
+    * otherwise <code>me</code> contains the exception which caused the
+    * abnormal close.
+    * 
+    * @param sessionID
+    *           the ID of the session
+    * @param me
+    *           <code>null</code> if the session was closed properly
+    */
+   void sessionDestroyed(long sessionID, MessagingException me);
+}

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -29,7 +29,7 @@
 import java.util.Set;
 
 import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionMessage;
@@ -150,11 +150,11 @@
       remotingConnection.send(serverTargetID, new PacketImpl(CONN_STOP));
    }
 
-   public void setFailureListener(final FailureListener listener) throws MessagingException
+   public void setRemotingSessionListener(final RemotingSessionListener listener) throws MessagingException
    {
       checkClosed();
       
-      remotingConnection.setFailureListener(listener);
+      remotingConnection.setRemotingSessionListener(listener);
    }
    
    public synchronized void close() throws MessagingException

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnection.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnection.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -1,6 +1,6 @@
 package org.jboss.messaging.core.client.impl;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
@@ -30,7 +30,7 @@
    
    Packet send(long targetID, long executorID, Packet packet, boolean oneWay) throws MessagingException;
    
-   void setFailureListener(FailureListener newListener);
+   void setRemotingSessionListener(RemotingSessionListener newListener);
    
    PacketDispatcher getPacketDispatcher();
 }

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnectionImpl.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/RemotingConnectionImpl.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -24,7 +24,7 @@
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.jboss.messaging.core.remoting.ConnectorRegistrySingleton.REGISTRY;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.client.Location;
 import org.jboss.messaging.core.client.ConnectionParams;
 import org.jboss.messaging.core.exception.MessagingException;
@@ -61,7 +61,7 @@
    
    private NIOSession session;
    
-   private FailureListener listener;
+   private RemotingSessionListener listener;
 
    private transient PacketDispatcher dispatcher;
 
@@ -106,7 +106,7 @@
          if (connector != null)
          { 
             if (listener != null)
-               connector.removeFailureListener(listener);
+               connector.removeSessionListener(listener);
             NIOConnector connectorFromRegistry = REGISTRY.removeConnector(location);
             if (connectorFromRegistry != null)
                connectorFromRegistry.disconnect();
@@ -181,7 +181,7 @@
       } 
    }
    
-   public synchronized void setFailureListener(final FailureListener newListener)
+   public synchronized void setRemotingSessionListener(final RemotingSessionListener newListener)
    {
       if (listener != null && newListener != null)
       {
@@ -190,11 +190,11 @@
 
       if (newListener != null)
       {
-         connector.addFailureListener(newListener);
+         connector.addSessionListener(newListener);
       }
       else 
       {
-         connector.removeFailureListener(listener);
+         connector.removeSessionListener(listener);
       }
       this.listener = newListener;
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -8,7 +8,7 @@
 
 import java.io.IOException;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -22,9 +22,9 @@
 
    boolean disconnect();
 
-   void addFailureListener(FailureListener listener);
+   void addSessionListener(RemotingSessionListener listener);
 
-   void removeFailureListener(FailureListener listener);
+   void removeSessionListener(RemotingSessionListener listener);
 
    String getServerURI();
 }
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/RemotingException.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/RemotingException.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/RemotingException.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting;
-
-import org.jboss.messaging.core.exception.MessagingException;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class RemotingException extends MessagingException
-{
-
-   // Constants -----------------------------------------------------
-
-   private static final long serialVersionUID = -6849945921631932738L;
-
-   // Attributes ----------------------------------------------------
-
-   private long sessionID;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public RemotingException(int code, String message, long sessionID)
-   {
-      super(code, message);
-      this.sessionID = sessionID;
-   }
-
-   // Public --------------------------------------------------------
-
-   public long getSessionID()
-   {
-      return sessionID;
-   }
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/RemotingService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/RemotingService.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/RemotingService.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.server.MessagingComponent;
 
@@ -26,7 +26,7 @@
 
    void removeInterceptor(Interceptor interceptor);
 
-   void addFailureListener(FailureListener listener);
+   void addRemotingSessionListener(RemotingSessionListener listener);
 
-   void removeFailureListener(FailureListener listener);  
+   void removeRemotingSessionListener(RemotingSessionListener listener);
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -10,7 +10,7 @@
 
 import java.io.IOException;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.remoting.NIOConnector;
 import org.jboss.messaging.core.remoting.NIOSession;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
@@ -74,11 +74,11 @@
       return INVM + "://localhost";
    }
    
-   public void addFailureListener(FailureListener listener)
+   public void addSessionListener(RemotingSessionListener listener)
    {      
    }
    
-   public void removeFailureListener(FailureListener listener)
+   public void removeSessionListener(RemotingSessionListener listener)
    {      
    }
 

Copied: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/CleanUpNotifier.java (from rev 4088, trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FailureNotifier.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/CleanUpNotifier.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/CleanUpNotifier.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.impl.mina;
+
+import org.jboss.messaging.core.exception.MessagingException;
+
+
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public interface CleanUpNotifier
+{
+   void fireCleanup(long sessionID, MessagingException e);
+}
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FailureNotifier.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FailureNotifier.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FailureNotifier.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -1,22 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.impl.mina;
-
-import org.jboss.messaging.core.exception.MessagingException;
-
-
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public interface FailureNotifier
-{
-   public abstract void fireFailure(MessagingException e);
-}
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FilterChainSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FilterChainSupport.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/FilterChainSupport.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -57,7 +57,7 @@
    
    public static void addKeepAliveFilter(final DefaultIoFilterChainBuilder filterChain,
          final KeepAliveFactory factory, final int keepAliveInterval,
-         final int keepAliveTimeout, final FailureNotifier notifier)
+         final int keepAliveTimeout, final CleanUpNotifier notifier)
    {
       assert filterChain != null;
       assert factory != null;

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -30,9 +30,9 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.ssl.SslFilter;
 import org.apache.mina.transport.socket.nio.NioSocketConnector;
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.ConnectionParams;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.client.Location;
-import org.jboss.messaging.core.client.ConnectionParams;
 import org.jboss.messaging.core.client.impl.ConnectionParamsImpl;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
@@ -41,7 +41,6 @@
 import org.jboss.messaging.core.remoting.NIOSession;
 import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
-import org.jboss.messaging.core.remoting.RemotingException;
 import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
 
 /**
@@ -50,7 +49,7 @@
  * @version <tt>$Revision$</tt>
  * 
  */
-public class MinaConnector implements NIOConnector, FailureNotifier
+public class MinaConnector implements NIOConnector, CleanUpNotifier
 {
    // Constants -----------------------------------------------------
 
@@ -72,7 +71,7 @@
    
    private IoSession session;
 
-   private List<FailureListener> listeners = new ArrayList<FailureListener>();
+   private List<RemotingSessionListener> listeners = new ArrayList<RemotingSessionListener>();
    private IoServiceListenerAdapter ioListener;
 
    // Static --------------------------------------------------------
@@ -211,7 +210,7 @@
       return closed;
    }
 
-   public synchronized void addFailureListener(final FailureListener listener)
+   public synchronized void addSessionListener(final RemotingSessionListener listener)
    {
       assert listener != null;
       assert connector != null;
@@ -222,7 +221,7 @@
          log.trace("added listener " + listener + " to " + this);
    }
 
-   public synchronized void removeFailureListener(FailureListener listener)
+   public synchronized void removeSessionListener(RemotingSessionListener listener)
    {
       assert listener != null;
       assert connector != null;
@@ -240,13 +239,18 @@
    
    // FailureNotifier implementation -------------------------------
    
-   public synchronized void fireFailure(MessagingException me)
+   public synchronized void fireCleanup(long sessionID, MessagingException me)
    {
-      for (FailureListener listener: listeners)
+      for (RemotingSessionListener listener: listeners)
       {
-         listener.onFailure(me);
+         listener.sessionDestroyed(sessionID, me);
       }
    }
+   
+   public void fireCleanup(long sessionID)
+   {
+      fireCleanup(sessionID, null);
+   }
 
    // Public --------------------------------------------------------
    
@@ -298,10 +302,8 @@
 
       public void sessionDestroyed(IoSession session)
       {
-         RemotingException re =
-            new RemotingException(MessagingException.INTERNAL_ERROR, "MINA session has been destroyed",
-            		session.getId());
-         fireFailure(re);
+         fireCleanup(session.getId(), 
+               new MessagingException(MessagingException.INTERNAL_ERROR, "MINA session has been destroyed"));
       }
    }
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -20,7 +20,6 @@
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.PacketHandlerRegistrationListener;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.RemotingException;
 import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
 import org.jboss.messaging.util.OrderedExecutorFactory;
 
@@ -41,7 +40,7 @@
 
    private final PacketDispatcher dispatcher;
 
-   private FailureNotifier failureNotifier;
+   private CleanUpNotifier failureNotifier;
 
    private final boolean closeSessionOnExceptionCaught;
 
@@ -54,7 +53,7 @@
 
    // Constructors --------------------------------------------------
    public MinaHandler(final PacketDispatcher dispatcher, final ExecutorService executorService,
-   		             final FailureNotifier failureNotifier, final boolean closeSessionOnExceptionCaught)
+   		             final CleanUpNotifier failureNotifier, final boolean closeSessionOnExceptionCaught)
    {
       assert dispatcher!= null;
       assert executorService != null;
@@ -92,10 +91,10 @@
       if (failureNotifier != null)
       {
          long serverSessionID = session.getId();
-         RemotingException re =
-         	new RemotingException(MessagingException.INTERNAL_ERROR, "unexpected exception", serverSessionID);
-         re.initCause(cause);
-         failureNotifier.fireFailure(re);
+         MessagingException me =
+         	new MessagingException(MessagingException.INTERNAL_ERROR, "unexpected exception");
+         me.initCause(cause);
+         failureNotifier.fireCleanup(serverSessionID, me);
       }
       if (closeSessionOnExceptionCaught)
       {

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaKeepAliveFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaKeepAliveFactory.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaKeepAliveFactory.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -11,7 +11,6 @@
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.KeepAliveFactory;
-import org.jboss.messaging.core.remoting.RemotingException;
 import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
 import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
 
@@ -32,14 +31,14 @@
 
    private KeepAliveFactory innerFactory;
 
-   private FailureNotifier notifier;
+   private CleanUpNotifier notifier;
 
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
    public MinaKeepAliveFactory(KeepAliveFactory factory,
-         FailureNotifier notifier)
+         CleanUpNotifier notifier)
    {
       assert factory != null;
 
@@ -73,10 +72,9 @@
          Pong pong = (Pong) response;
          if (pong.isSessionFailed() && notifier != null)
          {
-            // FIXME better error code
-            notifier.fireFailure(new RemotingException(
+            notifier.fireCleanup(session.getId(), new MessagingException(
                   MessagingException.CONNECTION_TIMEDOUT,
-                  "Session has failed on the server", session.getId()));
+                  "Session has failed on the server"));
          }
          return true;
       } else

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaService.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaService.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -30,15 +30,15 @@
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.jboss.beans.metadata.api.annotations.Install;
 import org.jboss.beans.metadata.api.annotations.Uninstall;
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.Interceptor;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
-import org.jboss.messaging.core.remoting.RemotingException;
 import org.jboss.messaging.core.remoting.RemotingService;
 import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
+import org.jboss.messaging.core.server.ConnectionManager;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -46,7 +46,7 @@
  * @version <tt>$Revision$</tt>
  * 
  */
-public class MinaService implements RemotingService, FailureNotifier
+public class MinaService implements RemotingService, CleanUpNotifier
 {
    // Constants -----------------------------------------------------
 
@@ -66,7 +66,7 @@
 
    private ExecutorService threadPool; 
    
-   private List<FailureListener> listeners = new ArrayList<FailureListener>();
+   private List<RemotingSessionListener> listeners = new ArrayList<RemotingSessionListener>();
 
    private ServerKeepAliveFactory factory;
    
@@ -105,14 +105,14 @@
       this.filters.remove(filter);
    }
 
-   public void addFailureListener(FailureListener listener)
+   public void addRemotingSessionListener(RemotingSessionListener listener)
    {
       assert listener != null;
 
       listeners.add(listener);
    }
 
-   public void removeFailureListener(FailureListener listener)
+   public void removeRemotingSessionListener(RemotingSessionListener listener)
    {
       assert listener != null;
 
@@ -222,21 +222,19 @@
 
    // FailureNotifier implementation -------------------------------
 
-   public void fireFailure(MessagingException me)
+   public void fireCleanup(long sessionID, MessagingException me)
    {
-      if (me instanceof RemotingException)
+      if (factory.getSessions().containsKey(sessionID))
       {
-         RemotingException re = (RemotingException) me;
-         long sessionID = re.getSessionID();
          long clientSessionID = factory.getSessions().containsKey(sessionID)?factory.getSessions().get(sessionID):0;
-         for (FailureListener listener : listeners)
+         for (RemotingSessionListener listener : listeners)
          {
-            listener.onFailure(new RemotingException(re.getCode(), re.getMessage(), clientSessionID));
+            listener.sessionDestroyed(clientSessionID, me);
          }
          factory.getSessions().remove(sessionID);  
-      }      
+      }
    }
-
+   
    // Public --------------------------------------------------------
 
    public void setKeepAliveFactory(ServerKeepAliveFactory factory)
@@ -281,14 +279,7 @@
 
       public void sessionDestroyed(IoSession session)
       {
-         if (session.isClosing())
-            return;
-
-         long sessionID = session.getId();
-         if (factory.getSessions().containsKey(sessionID))
-         {
-            fireFailure(new RemotingException(MessagingException.INTERNAL_ERROR, "MINA session destroyed", sessionID));
-         }
+         fireCleanup(session.getId(), null);
       }
-   }
+   }  
 }
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ConnectionManagerImpl.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -27,10 +27,9 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.RemotingException;
 import org.jboss.messaging.core.server.ConnectionManager;
 import org.jboss.messaging.core.server.ServerConnection;
 
@@ -43,7 +42,7 @@
  *
  * $Id: ConnectionManagerImpl.java 3778 2008-02-24 12:15:29Z timfox $
  */
-public class ConnectionManagerImpl implements ConnectionManager, FailureListener
+public class ConnectionManagerImpl implements ConnectionManager, RemotingSessionListener
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -113,15 +112,14 @@
    }      
 
    // FailureListener implementation --------------------------------------------------------------
-   
-   public void onFailure(MessagingException me)
+
+   public void sessionDestroyed(long sessionID, MessagingException me)
    {
-      if (me instanceof RemotingException)
+      if (me != null)
       {
-         RemotingException re = (RemotingException) me;
-         log.warn(re.getMessage(), re);
-         handleClientFailure(re.getSessionID(), true);
+         log.warn(me.getMessage(), me);
       }
+      closeConsumers(sessionID);
    }
    
    // Public ---------------------------------------------------------------------------------------
@@ -137,29 +135,20 @@
 
    // Private --------------------------------------------------------------------------------------
 
-   /**
-    * @param clientToServer - true if the failure has been detected on a direct connection from
-    *        client to this server, false if the failure has been detected while trying to send a
-    *        callback from this server to the client.
-    */
-   private synchronized void handleClientFailure(long remotingSessionID, boolean clientToServer)
-   {
-      log.warn("A problem has been detected " +
-         (clientToServer ?
-            "with the connection to remote client ":
-            "trying to send a message to remote client ") +
-         remotingSessionID + ". It is possible the client has exited without closing " +
-         "its connection(s) or the network has failed. All connection resources " +
-         "corresponding to that client process will now be removed.");
-
-      closeConsumers(remotingSessionID);
-      
-      dump();
-   }
-
    private synchronized void closeConsumers(long remotingClientSessionID)
    {
       List<ServerConnection> connectionEndpoints = endpoints.get(remotingClientSessionID);
+      
+      if (connectionEndpoints == null || connectionEndpoints.isEmpty())
+         return;
+      
+      // we still have connections open for the session
+      
+      log.warn("A problem has been detected with the connection to remote client " +
+            remotingClientSessionID + ". It is possible the client has exited without closing " +
+            "its connection(s) or the network has failed. All connection resources " +
+            "corresponding to that client process will now be removed.");
+
       // the connection endpoints are copied in a new list to avoid concurrent modification exception
       List<ServerConnection> copy;
       if (connectionEndpoints != null)
@@ -180,6 +169,8 @@
             log.error("Failed to close connection", e);
          }          
       }
+      
+      dump();
    }
    
    private void dump()

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -180,7 +180,7 @@
       }
       // Start the wired components
       securityDeployer.start();
-      remotingService.addFailureListener(connectionManager);
+      remotingService.addRemotingSessionListener(connectionManager);
       memoryManager.start();
       postOffice.start();
       
@@ -222,7 +222,7 @@
       securityDeployer.stop();
       queueSettingsDeployer.stop();
       deploymentManager.stop();
-      remotingService.removeFailureListener(connectionManager);
+      remotingService.removeRemotingSessionListener(connectionManager);
       connectionManager = null;
       memoryManager.stop();
       memoryManager = null;

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -45,7 +45,7 @@
 
 import org.jboss.messaging.core.client.ClientConnection;
 import org.jboss.messaging.core.client.ClientSession;
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.client.impl.ClientConnectionInternal;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
@@ -166,11 +166,11 @@
       {
          if (listener == null)
          {
-            connection.setFailureListener(null);                 
+            connection.setRemotingSessionListener(null);                 
          }
          else
          {
-            connection.setFailureListener(new JMSFailureListener());
+            connection.setRemotingSessionListener(new JMSFailureListener());
          }
          
          exceptionListener = listener;
@@ -457,10 +457,13 @@
 
    // Inner classes --------------------------------------------------------------------------------
    
-   private class JMSFailureListener implements FailureListener
+   private class JMSFailureListener implements RemotingSessionListener
    {
-      public void onFailure(final MessagingException me)
+      public void sessionDestroyed(long sessionID, MessagingException me)
       {
+         if (me == null)
+            return;
+         
          JMSException je = new JMSException(me.toString());
          
          je.initCause(me);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ClientKeepAliveTest.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -17,23 +17,23 @@
 import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
 
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
 
 import junit.framework.TestCase;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.client.impl.LocationImpl;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.KeepAliveFactory;
 import org.jboss.messaging.core.remoting.NIOSession;
-import org.jboss.messaging.core.remoting.RemotingException;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
 import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
 import org.jboss.messaging.core.remoting.impl.mina.ClientKeepAliveFactory;
 import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
 import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
 import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
+import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -87,14 +87,13 @@
 
       final CountDownLatch latch = new CountDownLatch(1);
 
-      FailureListener listener = new FailureListener() {
-         public void onFailure(MessagingException me)
+      RemotingSessionListener listener = new RemotingSessionListener() {
+         public void sessionDestroyed(long sessionID, MessagingException me)
          {
-            assertTrue(me instanceof RemotingException);
             latch.countDown();
          }
       };
-      service.addFailureListener(listener);
+      service.addRemotingSessionListener(listener);
 
       MinaConnector connector = new MinaConnector(new LocationImpl(TCP, "localhost", TestSupport.PORT), new PacketDispatcherImpl(null), factory);
       connector.connect();
@@ -103,7 +102,7 @@
             + TestSupport.KEEP_ALIVE_TIMEOUT + 2, SECONDS);
       assertFalse(firedKeepAliveNotification);
 
-      service.removeFailureListener(listener);
+      service.removeRemotingSessionListener(listener);
       connector.disconnect();
 
       verify(factory);
@@ -116,16 +115,14 @@
       final long[] clientSessionIDNotResponding = new long[1];
       final CountDownLatch latch = new CountDownLatch(1);
 
-      FailureListener listener = new FailureListener() {
-         public void onFailure(MessagingException me)
+      RemotingSessionListener listener = new RemotingSessionListener() {
+         public void sessionDestroyed(long sessionID, MessagingException me)
          {
-            assertTrue(me instanceof RemotingException);
-            RemotingException re = (RemotingException) me;
-            clientSessionIDNotResponding[0] = re.getSessionID();
+            clientSessionIDNotResponding[0] = sessionID;
             latch.countDown();
          }
       };
-      service.addFailureListener(listener);
+      service.addRemotingSessionListener(listener);
       
       MinaConnector connector = new MinaConnector(new LocationImpl(TCP, "localhost", TestSupport.PORT), new PacketDispatcherImpl(null), factory);
 
@@ -138,7 +135,7 @@
       assertNotNull(clientSessionIDNotResponding[0]);
       assertEquals(clientSessionID, clientSessionIDNotResponding[0]);
 
-      service.removeFailureListener(listener);
+      service.removeRemotingSessionListener(listener);
       connector.disconnect();
    }
 
@@ -178,27 +175,24 @@
          NIOSession session = connector.connect();
          long clientSessionID = session.getID();
 
-         final long[] clientSessionIDNotResponding = new long[1];
+         final AtomicLong clientSessionIDNotResponding = new AtomicLong(-1);
          final CountDownLatch latch = new CountDownLatch(1);
 
-         FailureListener listener = new FailureListener() {
-            public void onFailure(MessagingException me)
+         RemotingSessionListener listener = new RemotingSessionListener() {
+            public void sessionDestroyed(long sessionID, MessagingException me)
             {
-               assertTrue(me instanceof RemotingException);
-               RemotingException re = (RemotingException) me;
-               clientSessionIDNotResponding[0] = re.getSessionID();
+               clientSessionIDNotResponding.set(sessionID);
                latch.countDown();
             }
          };
-         service.addFailureListener(listener);
+         service.addRemotingSessionListener(listener);
 
          boolean firedKeepAliveNotification = latch.await(TestSupport.KEEP_ALIVE_INTERVAL
                + TestSupport.KEEP_ALIVE_TIMEOUT + 2, SECONDS);
          assertTrue("notification has not been received", firedKeepAliveNotification);
-         assertNotNull(clientSessionIDNotResponding[0]);
-         assertEquals(clientSessionID, clientSessionIDNotResponding[0]);
+         assertEquals(clientSessionID, clientSessionIDNotResponding.longValue());
 
-         service.removeFailureListener(listener);
+         service.removeRemotingSessionListener(listener);
          connector.disconnect();
 
       } finally
@@ -217,19 +211,17 @@
       KeepAliveFactory notRespondingfactory = new ClientKeepAliveFactoryNotResponding();
       KeepAliveFactory respondingfactory = new ClientKeepAliveFactory();
 
-      final long[] sessionIDNotResponding = new long[1];
+      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
       final CountDownLatch latch = new CountDownLatch(1);
 
-      FailureListener listener = new FailureListener() {
-         public void onFailure(MessagingException me)
+      RemotingSessionListener listener = new RemotingSessionListener() {
+         public void sessionDestroyed(long sessionID, MessagingException me)
          {
-            assertTrue(me instanceof RemotingException);
-            RemotingException re = (RemotingException) me;
-            sessionIDNotResponding[0] = re.getSessionID();
+            sessionIDNotResponding.set(sessionID);
             latch.countDown();
          }
       };
-      service.addFailureListener(listener);
+      service.addRemotingSessionListener(listener);
       
       MinaConnector connectorNotResponding = new MinaConnector(new LocationImpl(TCP, "localhost", TestSupport.PORT), new PacketDispatcherImpl(null), notRespondingfactory);
       MinaConnector connectorResponding = new MinaConnector(new LocationImpl(TCP, "localhost", TestSupport.PORT), new PacketDispatcherImpl(null), respondingfactory);
@@ -245,11 +237,10 @@
             + TestSupport.KEEP_ALIVE_TIMEOUT + 2, SECONDS);
       assertTrue("notification has not been received", firedKeepAliveNotification);
 
-      assertNotNull(sessionIDNotResponding[0]);
-      assertEquals(clientSessionIDNotResponding, sessionIDNotResponding[0]);
-      assertNotSame(clientSessionIDResponding, sessionIDNotResponding[0]);
+      assertEquals(clientSessionIDNotResponding, sessionIDNotResponding.longValue());
+      assertNotSame(clientSessionIDResponding, sessionIDNotResponding.longValue());
 
-      service.removeFailureListener(listener);
+      service.removeRemotingSessionListener(listener);
       connectorNotResponding.disconnect();
       connectorResponding.disconnect();
    }

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/FilterChainSupportTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/FilterChainSupportTest.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/FilterChainSupportTest.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -29,7 +29,7 @@
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.transport.socket.nio.NioSocketConnector;
 import org.jboss.messaging.core.remoting.KeepAliveFactory;
-import org.jboss.messaging.core.remoting.impl.mina.FailureNotifier;
+import org.jboss.messaging.core.remoting.impl.mina.CleanUpNotifier;
 import org.jboss.messaging.core.remoting.impl.mina.FilterChainSupport;
 import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
 
@@ -74,7 +74,7 @@
 
       DefaultIoFilterChainBuilder filterChain = new DefaultIoFilterChainBuilder();
       KeepAliveFactory factory = createMock(KeepAliveFactory.class);
-      FailureNotifier notifier = createMock(FailureNotifier.class);
+      CleanUpNotifier notifier = createMock(CleanUpNotifier.class);
 
       replay(factory, notifier);
 

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/MinaKeepAliveFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/MinaKeepAliveFactoryTest.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/MinaKeepAliveFactoryTest.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -6,6 +6,7 @@
  */
 package org.jboss.messaging.tests.integration.core.remoting.mina;
 
+import static org.easymock.EasyMock.anyLong;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
@@ -18,7 +19,7 @@
 import org.apache.mina.common.IoSession;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.KeepAliveFactory;
-import org.jboss.messaging.core.remoting.impl.mina.FailureNotifier;
+import org.jboss.messaging.core.remoting.impl.mina.CleanUpNotifier;
 import org.jboss.messaging.core.remoting.impl.mina.MinaKeepAliveFactory;
 import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
 
@@ -44,7 +45,7 @@
    {
       IoSession session = createMock(IoSession.class);
       KeepAliveFactory factory = createMock(KeepAliveFactory.class);
-      FailureNotifier notifier = createMock(FailureNotifier.class);
+      CleanUpNotifier notifier = createMock(CleanUpNotifier.class);
       replay(session, factory, notifier);
 
       MinaKeepAliveFactory minaFactory = new MinaKeepAliveFactory(factory, notifier);
@@ -60,7 +61,7 @@
       long sessionID = randomLong();
       Pong pong = new Pong(sessionID, false);
       KeepAliveFactory factory = createMock(KeepAliveFactory.class);
-      FailureNotifier notifier = createMock(FailureNotifier.class);
+      CleanUpNotifier notifier = createMock(CleanUpNotifier.class);
       replay(session, factory, notifier);
 
       MinaKeepAliveFactory minaFactory = new MinaKeepAliveFactory(factory, notifier);
@@ -77,11 +78,11 @@
       expect(session.getId()).andStubReturn(sessionID);
       Pong pong = new Pong(sessionID, true);
       KeepAliveFactory factory = createMock(KeepAliveFactory.class);
-      FailureNotifier notifier = createMock(FailureNotifier.class);
-      notifier.fireFailure(isA(MessagingException.class));
+      CleanUpNotifier notifier = createMock(CleanUpNotifier.class);
+      notifier.fireCleanup(anyLong(), isA(MessagingException.class));
       expectLastCall().once();
       replay(session, factory, notifier);
-
+      
       MinaKeepAliveFactory minaFactory = new MinaKeepAliveFactory(factory, notifier);
 
       assertTrue(minaFactory.isResponse(session, pong));

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/mina/ServerKeepAliveTest.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -10,21 +10,21 @@
 import static org.jboss.messaging.core.remoting.TransportType.TCP;
 
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
 
 import junit.framework.TestCase;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.NIOSession;
-import org.jboss.messaging.core.remoting.RemotingException;
-import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
 import org.jboss.messaging.core.remoting.impl.PacketDispatcherImpl;
 import org.jboss.messaging.core.remoting.impl.mina.MinaConnector;
 import org.jboss.messaging.core.remoting.impl.mina.MinaService;
 import org.jboss.messaging.core.remoting.impl.mina.ServerKeepAliveFactory;
 import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
 import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
+import org.jboss.messaging.tests.unit.core.remoting.impl.ConfigurationHelper;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -87,29 +87,28 @@
 
       MinaConnector connector = new MinaConnector(service
             .getConfiguration().getLocation(), service.getConfiguration().getConnectionParams(), new PacketDispatcherImpl(null));
-      final long[] sessionIDNotResponding = new long[1];
+
+      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
       final CountDownLatch latch = new CountDownLatch(1);
 
-      FailureListener listener = new FailureListener()
+      RemotingSessionListener listener = new RemotingSessionListener()
       {
-         public void onFailure(MessagingException me)
+         public void sessionDestroyed(long sessionID, MessagingException me)
          {
-            assertTrue(me instanceof RemotingException);
-            RemotingException re = (RemotingException) me;
-            sessionIDNotResponding[0] = re.getSessionID();
+            sessionIDNotResponding.set(sessionID);
             latch.countDown();
          }
       };
-      connector.addFailureListener(listener);
+      connector.addSessionListener(listener);
 
       NIOSession session = connector.connect();
 
       boolean firedKeepAliveNotification = latch.await(TestSupport.KEEP_ALIVE_INTERVAL
             + TestSupport.KEEP_ALIVE_TIMEOUT + 2, SECONDS);
       assertTrue(firedKeepAliveNotification);
-      assertEquals(session.getID(), sessionIDNotResponding[0]);
+      assertEquals(session.getID(), sessionIDNotResponding.longValue());
 
-      connector.removeFailureListener(listener);
+      connector.removeSessionListener(listener);
       connector.disconnect();
    }
 
@@ -142,29 +141,28 @@
 
       MinaConnector connector = new MinaConnector(service
             .getConfiguration().getLocation(), new PacketDispatcherImpl(null));
-      final long[] sessionIDNotResponding = new long[1];
+
+      final AtomicLong sessionIDNotResponding = new AtomicLong(-1);
       final CountDownLatch latch = new CountDownLatch(1);
 
-      FailureListener listener = new FailureListener()
+      RemotingSessionListener listener = new RemotingSessionListener()
       {
-         public void onFailure(MessagingException me)
+         public void sessionDestroyed(long sessionID, MessagingException me)
          {
-            assertTrue(me instanceof RemotingException);
-            RemotingException re = (RemotingException) me;
-            sessionIDNotResponding[0] = re.getSessionID();
+            sessionIDNotResponding.set(sessionID);
             latch.countDown();
          }
       };
-      connector.addFailureListener(listener);
+      connector.addSessionListener(listener);
 
       NIOSession session = connector.connect();
 
       boolean firedKeepAliveNotification = latch.await(TestSupport.KEEP_ALIVE_INTERVAL
             + TestSupport.KEEP_ALIVE_TIMEOUT + 2, SECONDS);
       assertTrue(firedKeepAliveNotification);
-      assertEquals(session.getID(), sessionIDNotResponding[0]);
+      assertEquals(session.getID(), sessionIDNotResponding.longValue());
 
-      connector.removeFailureListener(listener);
+      connector.removeSessionListener(listener);
       connector.disconnect();
    }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java	2008-04-22 12:37:58 UTC (rev 4095)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java	2008-04-22 14:27:13 UTC (rev 4096)
@@ -28,7 +28,7 @@
 import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
 
-import org.jboss.messaging.core.client.FailureListener;
+import org.jboss.messaging.core.client.RemotingSessionListener;
 import org.jboss.messaging.core.client.ClientConnectionFactory;
 import org.jboss.messaging.core.client.ClientConnection;
 import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
@@ -113,15 +113,15 @@
       assertActiveConnectionsOnTheServer(1);
 
       final CountDownLatch exceptionLatch = new CountDownLatch(2);
-      conn.setFailureListener(new FailureListener()
+      conn.setRemotingSessionListener(new RemotingSessionListener()
       {
-         public void onFailure(MessagingException me)
+         public void sessionDestroyed(long sessionID, MessagingException me)
          {
             exceptionLatch.countDown();
          }
       });
-      FailureListener listener = new FailureListenerWithLatch(exceptionLatch);
-      minaService.addFailureListener(listener);
+      RemotingSessionListener listener = new FailureListenerWithLatch(exceptionLatch);
+      minaService.addRemotingSessionListener(listener);
 
       networkFailureFilter.messageSentThrowsException = new IOException(
             "Client is unreachable");
@@ -140,7 +140,7 @@
       {
       }
 
-      minaService.removeFailureListener(listener);
+      minaService.removeRemotingSessionListener(listener);
    }
 
    public void testServerResourcesCleanUpWhenClientCommDropsPacket()
@@ -152,8 +152,8 @@
 
       final CountDownLatch exceptionLatch = new CountDownLatch(1);
 
-      FailureListener listener = new FailureListenerWithLatch(exceptionLatch);
-      minaService.addFailureListener(listener);
+      RemotingSessionListener listener = new FailureListenerWithLatch(exceptionLatch);
+      minaService.addRemotingSessionListener(listener);
 
       assertActiveConnectionsOnTheServer(1);
 
@@ -180,7 +180,7 @@
 
    // Private -------------------------------------------------------
 
-   private final class FailureListenerWithLatch implements FailureListener
+   private final class FailureListenerWithLatch implements RemotingSessionListener
    {
       private final CountDownLatch exceptionLatch;
 
@@ -189,7 +189,7 @@
          this.exceptionLatch = exceptionLatch;
       }
 
-      public void onFailure(MessagingException me)
+      public void sessionDestroyed(long sessionID, MessagingException me)
       {
          log.warn("got expected exception on the server");
          exceptionLatch.countDown();




More information about the jboss-cvs-commits mailing list