[jboss-cvs] JBoss Messaging SVN: r3350 - in branches/Branch_JBMESSAGING-544: src/main/org/jboss/jms/client/delegate and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 20 12:40:53 EST 2007


Author: jmesnil
Date: 2007-11-20 12:40:52 -0500 (Tue, 20 Nov 2007)
New Revision: 3350

Added:
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/StopConnectionMessageCodec.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java
Modified:
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/container/ConnectionAspect.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java
   branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
   branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-544: Replace client-server transport with NIO based transport
* added packets & codecs to stop a JMS connection


Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/container/ConnectionAspect.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/container/ConnectionAspect.java	2007-11-20 16:15:07 UTC (rev 3349)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/container/ConnectionAspect.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -178,19 +178,19 @@
    		
 	      ConnectionState state = getConnectionState(invocation);
 	
-//	      JMSRemotingConnection remotingConnection = state.getRemotingConnection();
-//	
-//	      // remove the consolidated remoting connection listener
-//	
+	      JMSRemotingConnection remotingConnection = state.getRemotingConnection();
+	
+	      // remove the consolidated remoting connection listener
+	
 //	      ConsolidatedRemotingConnectionListener l = remotingConnection.removeConnectionListener();
 //	      if (l != null)
 //	      {
 //	         l.clear();
 //	      }
-//	
-//	      // Finished with the connection - we need to shutdown callback server
-//	      remotingConnection.stop();
-//	       
+	
+	      // Finished with the connection - we need to shutdown callback server
+	      remotingConnection.stop();
+	       
 	      // Remove reference to message ID generator
 	      MessageIdGeneratorFactory.instance.checkInGenerator(state.getServerID());
 	      

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2007-11-20 16:15:07 UTC (rev 3349)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -45,7 +45,6 @@
 import org.jboss.jms.wireformat.ConnectionCreateSessionDelegateRequest;
 import org.jboss.jms.wireformat.ConnectionGetPreparedTransactionsRequest;
 import org.jboss.jms.wireformat.ConnectionStartRequest;
-import org.jboss.jms.wireformat.ConnectionStopRequest;
 import org.jboss.jms.wireformat.RequestSupport;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
@@ -59,6 +58,7 @@
 import org.jboss.messaging.core.remoting.wireformat.SendTransactionMessage;
 import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
 import org.jboss.messaging.core.remoting.wireformat.StartConnectionMessage;
+import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
 import org.jboss.messaging.util.Version;
 
 /**
@@ -338,9 +338,21 @@
 
    public void stop() throws JMSException
    {
-      RequestSupport req = new ConnectionStopRequest(id, version);
+      assert newClient != null;
 
-      doInvoke(client, req);
+      StopConnectionMessage message = new StopConnectionMessage();
+      message.setTargetID(id);
+      try
+      {
+         newClient.sendBlocking(message);
+      } catch (TimeoutException e)
+      {
+         e.printStackTrace();
+      }
+
+//      RequestSupport req = new ConnectionStopRequest(id, version);
+//
+//      doInvoke(client, req);
    }
 
    public MessagingXid[] getPreparedTransactions() throws JMSException

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-11-20 16:15:07 UTC (rev 3349)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -25,6 +25,7 @@
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDTRANSACTION;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STARTCONNECTION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CLOSING;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
@@ -872,6 +873,13 @@
             } else if (type == MSG_STARTCONNECTION)
             {
                start();
+            } else if (type == MSG_STOPCONNECTION)
+            {
+               stop();
+               
+               NullPacket response = new NullPacket();
+               response.normalize(packet);
+               session.write(response);               
             } else if (type == REQ_CLOSING)
             {
                org.jboss.messaging.core.remoting.wireformat.ClosingRequest request = (org.jboss.messaging.core.remoting.wireformat.ClosingRequest) packet;

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java	2007-11-20 16:15:07 UTC (rev 3349)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -35,6 +35,7 @@
 import org.jboss.messaging.core.remoting.wireformat.SendTransactionMessage;
 import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
 import org.jboss.messaging.core.remoting.wireformat.StartConnectionMessage;
+import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
 import org.jboss.messaging.core.remoting.wireformat.TextPacket;
 
 /**
@@ -121,6 +122,10 @@
       super.addMessageEncoder(StartConnectionMessage.class,
             StartConnectionMessageCodec.class);
 
+      super.addMessageDecoder(StopConnectionMessageCodec.class);
+      super.addMessageEncoder(StopConnectionMessage.class,
+            StopConnectionMessageCodec.class);
+
       super.addMessageDecoder(ChangeRateMessageCodec.class);
       super.addMessageEncoder(ChangeRateMessage.class,
             ChangeRateMessageCodec.class);

Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/StopConnectionMessageCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/StopConnectionMessageCodec.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/StopConnectionMessageCodec.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class StopConnectionMessageCodec extends
+      AbstractPacketCodec<StopConnectionMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public StopConnectionMessageCodec()
+   {
+      super(MSG_STOPCONNECTION);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(IoSession session, StopConnectionMessage message,
+         IoBuffer out) throws Exception
+   {
+      // no body
+      out.putInt(0);
+   }
+
+   @Override
+   protected StopConnectionMessage decodeBody(IoSession session, IoBuffer in)
+         throws Exception
+   {
+      in.getInt(); // skip body length
+
+      return new StopConnectionMessage();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java	2007-11-20 16:15:07 UTC (rev 3349)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -26,17 +26,18 @@
    REQ_CREATESESSION         ((byte) 8),
    RESP_CREATESESSION        ((byte) 9),
    MSG_STARTCONNECTION       ((byte)10),
-   MSG_SENDTRANSACTION       ((byte)11),
-   RESP_SENDTRANSACTION      ((byte)12),
-   REQ_GETCLIENTID           ((byte)13),
-   RESP_GETCLIENTID          ((byte)14),
-   MSG_SETCLIENTID           ((byte)15),
+   MSG_STOPCONNECTION        ((byte)11),
+   MSG_SENDTRANSACTION       ((byte)12),
+   RESP_SENDTRANSACTION      ((byte)13),
+   REQ_GETCLIENTID           ((byte)14),
+   RESP_GETCLIENTID          ((byte)15),
+   MSG_SETCLIENTID           ((byte)16),
    // Session
-   REQ_CREATECONSUMER        ((byte)16),
-   RESP_CREATECONSUMER       ((byte)17),  
-   REQ_CREATEBROWSER         ((byte)18),
-   RESP_CREATEBROWSER        ((byte)19),
-   MSG_SENDMESSAGE           ((byte)20),
+   REQ_CREATECONSUMER        ((byte)17),
+   RESP_CREATECONSUMER       ((byte)18),  
+   REQ_CREATEBROWSER         ((byte)19),
+   RESP_CREATEBROWSER        ((byte)20),
+   MSG_SENDMESSAGE           ((byte)21),
    MSG_DELIVERMESSAGE        ((byte)22),
    REQ_ACKDELIVERY           ((byte)23),
    RESP_ACKDELIVERY          ((byte)24),

Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java	                        (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class StopConnectionMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public StopConnectionMessage()
+   {
+      super(MSG_STOPCONNECTION);
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java	2007-11-20 16:15:07 UTC (rev 3349)
+++ branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java	2007-11-20 17:40:52 UTC (rev 3350)
@@ -18,6 +18,7 @@
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDTRANSACTION;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STARTCONNECTION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.NULL;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_ACKDELIVERY;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CLOSING;
@@ -88,6 +89,7 @@
 import org.jboss.messaging.core.remoting.wireformat.SendTransactionMessage;
 import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
 import org.jboss.messaging.core.remoting.wireformat.StartConnectionMessage;
+import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
 import org.jboss.messaging.core.remoting.wireformat.TextPacket;
 
 /**
@@ -355,7 +357,17 @@
       assertTrue(decodedPacket instanceof StartConnectionMessage);
       assertEquals(MSG_STARTCONNECTION, decodedPacket.getType());
    }
+   
+   public void testStopConnectionMessage() throws Exception
+   {
+      StopConnectionMessage packet = new StopConnectionMessage();
 
+      AbstractPacket decodedPacket = encodeAndDecode(packet);
+
+      assertTrue(decodedPacket instanceof StopConnectionMessage);
+      assertEquals(MSG_STOPCONNECTION, decodedPacket.getType());
+   }
+
    public void testChangeRateMessage() throws Exception
    {
       ChangeRateMessage message = new ChangeRateMessage(0.63f);




More information about the jboss-cvs-commits mailing list