[jboss-cvs] JBoss Messaging SVN: r7697 - in trunk: tests/src/org/jboss/messaging/tests/integration/client and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 10 06:37:23 EDT 2009


Author: timfox
Date: 2009-08-10 06:37:23 -0400 (Mon, 10 Aug 2009)
New Revision: 7697

Modified:
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
   trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionFactoryTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/ManualReconnectionToSingleServerTest.java
Log:
reworked exceptionlistener fix

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java	2009-08-10 08:47:31 UTC (rev 7696)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java	2009-08-10 10:37:23 UTC (rev 7697)
@@ -229,8 +229,8 @@
          sendMessageInChunks(sendBlocking, msg);
       }
       else if (sendBlocking)
-      {
-         channel.sendBlocking(message);
+      {         
+         channel.sendBlocking(message);         
       }
       else
       {

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java	2009-08-10 08:47:31 UTC (rev 7696)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java	2009-08-10 10:37:23 UTC (rev 7697)
@@ -657,10 +657,23 @@
             {
                // Fail the old connections so their listeners get called
 
+               //We need to destroy the current connections - since we might have connected ok just couldn't
+               //find session, but we don't want to call the FailureListeners on them - these will get called when
+               //we close the old connections (which have the same failureListeners)
+               
+               for (ConnectionEntry entry : connections.values())
+               {                  
+                  entry.connection.setFailureListeners(new ArrayList<FailureListener>());
+               }
+               
+               failConnections(me);
+               
+               //Then we need to destroy the old connections - pingers will already have been closed for these               
+                                        
                for (RemotingConnection connection : oldConnections)
-               {
-                  connection.fail(me);
-               }
+               {                  
+                  connection.fail(me);                  
+               }               
             }
          }
          else

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionFactoryTest.java	2009-08-10 08:47:31 UTC (rev 7696)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/SessionFactoryTest.java	2009-08-10 10:37:23 UTC (rev 7697)
@@ -23,6 +23,10 @@
 
 import static org.jboss.messaging.tests.util.RandomUtil.randomString;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -65,6 +69,29 @@
    private TransportConfiguration liveTC;
 
    private TransportConfiguration backupTC;
+   
+   public void testSerializable() throws Exception
+   {
+      ClientSessionFactory cf = new ClientSessionFactoryImpl();
+      
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+      
+      oos.writeObject(cf);
+      
+      oos.close();
+      
+      byte[] bytes = baos.toByteArray();
+      
+      ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+      
+      ObjectInputStream ois = new ObjectInputStream(bais);
+      
+      ClientSessionFactoryImpl csi = (ClientSessionFactoryImpl)ois.readObject();
+      
+      assertNotNull(csi);
+   }
 
    public void testDefaultConstructor() throws Exception
    {

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/ManualReconnectionToSingleServerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/ManualReconnectionToSingleServerTest.java	2009-08-10 08:47:31 UTC (rev 7696)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/ManualReconnectionToSingleServerTest.java	2009-08-10 10:37:23 UTC (rev 7697)
@@ -94,6 +94,8 @@
    private boolean afterRestart = false;
 
    private boolean receivedMessagesAfterRestart = false;
+   
+   private int callTimeout;
 
    private MessageListener listener = new MessageListener()
    {
@@ -137,37 +139,46 @@
 
    public void testExceptionListener() throws Exception
    {
-//      connect();
-//
-//      int num = 10;
-//      for (int i = 0; i < num; i++)
-//      {
-//         try
-//         {
-//            Message message = session.createTextMessage((new Date()).toString());
-//            producer.send(message);
-//            Thread.sleep(500);
-//         }
-//         catch (Exception e)
-//         {
-//            e.printStackTrace();
-//         }
-//
-//         if (i == num / 2)
-//         {
-//            killServer();
-//            Thread.sleep(5000);
-//            restartServer();
-//            afterRestart = true;
-//         }
-//      }
-//
-//      boolean gotException = exceptionLatch.await(10, SECONDS);
-//      assertTrue(gotException);
-//
-//      assertTrue(receivedMessagesAfterRestart);
-//      connection.close();
+      long start = System.currentTimeMillis();
+      
+      connect();
 
+      int num = 10;
+      for (int i = 0; i < num; i++)
+      {
+         try
+         {
+            Message message = session.createTextMessage((new Date()).toString());
+            producer.send(message);
+            Thread.sleep(500);
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+
+         if (i == num / 2)
+         {
+            killServer();
+            Thread.sleep(5000);
+            restartServer();
+            afterRestart = true;
+         }
+      }
+
+      boolean gotException = exceptionLatch.await(10, SECONDS);
+      assertTrue(gotException);
+
+      assertTrue(receivedMessagesAfterRestart);
+      connection.close();
+      
+      long end = System.currentTimeMillis();
+      
+      log.info("That took " + (end - start));
+      
+      //Make sure it doesn't pass by just timing out on blocking send
+      assertTrue(end - start < callTimeout);
+
    }
 
    // Package protected ---------------------------------------------
@@ -229,7 +240,7 @@
       double retryIntervalMultiplier = 1.0;
       int reconnectAttempts = -1;
       boolean failoverOnServerShutdown = true;
-      int callTimeout = 5000;
+      callTimeout = 30000;
 
       List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
       connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(NettyConnectorFactory.class.getName()),




More information about the jboss-cvs-commits mailing list