[jboss-cvs] JBoss Messaging SVN: r4878 - in branches/Branch_Message_Chunking_new: src/config and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 27 06:43:33 EDT 2008


Author: ataylor
Date: 2008-08-27 06:43:32 -0400 (Wed, 27 Aug 2008)
New Revision: 4878

Modified:
   branches/Branch_Message_Chunking_new/examples/jms/src/org/jboss/jms/example/QueueExample.java
   branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/Message.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/EncoderImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConsumerFlowCreditMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/MessagingExceptionMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketsConfirmedMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerFlowCreditMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerSendMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReceiveMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBrowserHasNextMessageResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCancelMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateQueueMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXACommitMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAEndMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAForgetMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAJoinMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAPrepareMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResumeMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXARollbackMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAStartMessage.java
   branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingHandlerImplTest.java
Log:
now create buffer to exact size needed

Modified: branches/Branch_Message_Chunking_new/examples/jms/src/org/jboss/jms/example/QueueExample.java
===================================================================
--- branches/Branch_Message_Chunking_new/examples/jms/src/org/jboss/jms/example/QueueExample.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/examples/jms/src/org/jboss/jms/example/QueueExample.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -49,7 +49,7 @@
          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
          final MessageProducer producer = session.createProducer(queue);
          final BytesMessage message = session.createBytesMessage();
-         byte[] bytes = new byte[1024];
+         byte[] bytes = new byte[812];
          for(int i = 0; i < bytes.length; i++)
          {
             bytes[i] = (byte) i;

Modified: branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml
===================================================================
--- branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml	2008-08-27 10:43:32 UTC (rev 4878)
@@ -35,7 +35,7 @@
 
       <!-- Enable/Disable Nagle's Algorithm (resp. true/false)                           -->
       <!-- This setting is taken into account only when remoting-transport is set to TCP -->
-      <remoting-tcp-nodelay>true</remoting-tcp-nodelay>
+      <remoting-tcp-nodelay>false</remoting-tcp-nodelay>
 
       <!-- Set the TCP Receive Buffer size (SO_RCVBUF).                                    -->
       <!-- Set it to -1 if you want to use the value hinted by the Operating System      -->

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/Message.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/Message.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/Message.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -69,7 +69,7 @@
    
    int getEncodeSize();
 
-   void encodeForTransport(Encoder buffer);
+   void encodeForTransport(Encoder buffer, boolean encodeBodySeperately);
 
    void decodeForTransport(Encoder buffer);
    

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -132,7 +132,7 @@
 
    // Message implementation ----------------------------------------
 
-   public void encodeForTransport(Encoder buff)
+   public void encodeForTransport(Encoder buff, boolean encodeBodySeperately)
    {
       buff.putSimpleString(getDestination());
       buff.putByte(getType());
@@ -141,13 +141,13 @@
       buff.putLong(getTimestamp());
       buff.putByte(getPriority());
       getProperties().encode(buff);
-      if(buffers.size() == 1 && buffers.get(0).limit() - PacketImpl.BUFFER_HEADER_SIZE <= MAX_BUFFER_SIZE)
+      if(!encodeBodySeperately)
       {
          int offSet = isBodySplit? PacketImpl.BUFFER_HEADER_SIZE:0;
          buff.putInt(getBodySize());
          //are we splitting the buffers.
          buff.putBoolean(false);
-         buff.putBytes(buffers.get(0).array(), offSet, buffers.get(0).limit());
+         buff.putBytes(buffers.get(0).array(), offSet, getBodySize());
       }
       else
       {

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/EncoderImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/EncoderImpl.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/EncoderImpl.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 package org.jboss.messaging.core.remoting.impl;
 
 import org.jboss.messaging.core.remoting.Encoder;
+import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
 import org.jboss.messaging.core.transaction.impl.XidImpl;
@@ -40,7 +41,6 @@
 public class EncoderImpl implements Encoder
 {
    private static final Charset utf8 = Charset.forName("UTF-8");
-   public static final int MAX_BUFFER_SIZE=1024 * 64;
    protected List<MessagingBuffer> buffers = new ArrayList<MessagingBuffer>();
    protected MessagingBuffer currentBuffer = null;
    private int bufferPos = 0;
@@ -128,9 +128,9 @@
 
    public void putBytes(byte[] bytes, int i, int i1)
    {
-      if(MAX_BUFFER_SIZE >= currentBuffer.position() + (i1 - i))
+      if(PacketImpl.MAX_BUFFER_SIZE + PacketImpl.BUFFER_HEADER_SIZE >= currentBuffer.position() + i1)
       {
-         currentBuffer.putBytes(bytes, i, i1 - i);
+         currentBuffer.putBytes(bytes, i, i1);
          pos += (i1 - i);
       }
       else
@@ -138,7 +138,7 @@
          int written = 0;
          while(written < i1)
          {
-            int left = MAX_BUFFER_SIZE - currentBuffer.position();
+            int left = PacketImpl.MAX_BUFFER_SIZE - currentBuffer.position();
             int towrite = left + written > i1?i1 - written:left;
             currentBuffer.putBytes(bytes, i, towrite);
             written+=towrite;
@@ -431,6 +431,7 @@
          buffer.flip();
          bodySize += buffer.limit() - PacketImpl.BUFFER_HEADER_SIZE;
       }
+      currentBuffer = buffers.size() > 0?buffers.get(0):null;
       pos = 0;
    }
 
@@ -442,6 +443,7 @@
       {
          buffer.rewind();
       }
+      currentBuffer = buffers.size() > 0?buffers.get(0):null;
    }
 
    public int remaining()
@@ -467,6 +469,79 @@
       }
    }
 
+   protected int getNullableStringSize(String... strings)
+   {
+      int size = 0;
+      for (String string : strings)
+      {
+         if (string == null)
+         {
+            size += DataConstants.SIZE_BYTE;
+         }
+         else
+         {
+            size += DataConstants.SIZE_BYTE;
+            size += DataConstants.SIZE_INT;
+            size += DataConstants.SIZE_CHAR * string.length();
+         }
+      }
+      return size;
+   }
+
+   protected int getStringSize(String... strings)
+   {
+      int size = 0;
+      for (String string : strings)
+      {
+         size += DataConstants.SIZE_INT;
+         size += DataConstants.SIZE_CHAR * string.length();
+      }
+      return size;
+   }
+
+
+   protected int getSimpleStringSize(SimpleString... strings)
+   {
+      int size = 0;
+      for (SimpleString string : strings)
+      {
+         size += DataConstants.SIZE_INT;
+         size += DataConstants.SIZE_BYTE * string.getData().length;
+      }
+      return size;
+   }
+
+   protected int getNullableSimpleStringSize(SimpleString... strings)
+   {
+      int size = 0;
+      for (SimpleString string : strings)
+      {
+         if (string == null)
+         {
+            size += DataConstants.SIZE_BYTE;
+         }
+         else
+         {
+            size += DataConstants.SIZE_BYTE;
+            size += DataConstants.SIZE_INT;
+            size += DataConstants.SIZE_BYTE * string.getData().length;
+         }
+      }
+      return size;
+   }
+
+   protected int getXidSize(Xid... xids)
+   {
+      int size = 0;
+      for (Xid xid : xids)
+      {
+         size += DataConstants.SIZE_INT * 3;
+         size += DataConstants.SIZE_BYTE * xid.getBranchQualifier().length;
+         size += DataConstants.SIZE_BYTE * xid.getGlobalTransactionId().length;
+      }
+      return size;
+   }
+
    private void checkReadSpace(int size)
    {
       if(currentBuffer.position() + size > currentBuffer.limit())
@@ -477,7 +552,7 @@
 
    private void checkWriteSpace(int size)
    {
-      if(currentBuffer.position() + size >= MAX_BUFFER_SIZE)
+      if(currentBuffer.position() + size >= PacketImpl.MAX_BUFFER_SIZE)
       {
          setNextFragment();
       }
@@ -498,4 +573,43 @@
       bufferPos++;
       currentBuffer = buffers.get(bufferPos);
    }
+
+   public static void main(String[] args)
+   {
+      IoBufferWrapper buffer = new IoBufferWrapper(1024);
+      EncoderImpl encoder = new EncoderImpl();
+      encoder.buffers.add(buffer);
+      encoder.currentBuffer = buffer;
+      long start = System.currentTimeMillis();
+      for(int i = 0; i < 100000000; i++)
+      {
+         encoder.putByte((byte) 7);
+      }
+      long time = System.currentTimeMillis() - start;
+      System.out.println("time = " + time);
+      encoder.rewind();
+      start = System.currentTimeMillis();
+      for(int i = 0; i < 100000000; i++)
+      {
+         try
+         {
+            encoder.getByte();
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+         }
+      }
+      time = System.currentTimeMillis() - start;
+      System.out.println("time = " + time);
+   }
+
+   protected void resetBuffers(MessagingBuffer buffer)
+   {
+      currentBuffer = buffer;
+      buffers.add(currentBuffer);
+      bodySize = 0;
+      pos = 0;
+   }
+
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConsumerFlowCreditMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConsumerFlowCreditMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConsumerFlowCreditMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -90,7 +92,11 @@
 
    // Protected -----------------------------------------------------
 
-   // Private -------------------------------------------------------
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_INT;
+   }
+// Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -174,6 +176,16 @@
 
    // Protected -----------------------------------------------------
 
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_INT +
+            DataConstants.SIZE_BOOLEAN * 3 +
+            DataConstants.SIZE_LONG +
+            getStringSize(name) +
+            getNullableStringSize(username, password);
+   }
+
+
    // Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateSessionResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -116,7 +118,11 @@
    }
 
    // Package protected ---------------------------------------------
-
+    protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_INT +
+            DataConstants.SIZE_LONG * 2;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/MessagingExceptionMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/MessagingExceptionMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/MessagingExceptionMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -23,6 +23,7 @@
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
 import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.util.DataConstants;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -94,9 +95,11 @@
    }
    
    // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_INT +
+            getNullableStringSize(exception.getMessage());
+   }
    // Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -28,6 +28,7 @@
 import org.jboss.messaging.core.remoting.impl.EncoderImpl;
 import org.jboss.messaging.core.remoting.spi.Connection;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.util.DataConstants;
 import static org.jboss.messaging.util.DataConstants.SIZE_INT;
 
 import java.util.List;
@@ -46,6 +47,8 @@
 
    public static final long NO_ID_SET = -1L;
 
+   public static final int MAX_BUFFER_SIZE=1450;
+
    public static final int INITIAL_BUFFER_SIZE = 1024;
 
    public static final int BUFFER_HEADER_SIZE = 9;
@@ -197,10 +200,9 @@
 
    public List<MessagingBuffer> encode(Connection connection,int packetId)
    {
-      currentBuffer = connection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE + PacketImpl.BUFFER_HEADER_SIZE);//The standard header fields
+      int encodeSize = getEncodeSize();
+      resetBuffers(connection.createBuffer((encodeSize < MAX_BUFFER_SIZE?encodeSize: MAX_BUFFER_SIZE) + PacketImpl.BUFFER_HEADER_SIZE));//The standard header fields);
 
-      buffers.add(currentBuffer);
-
       //length filled at end
       currentBuffer.putInt(-1);
       //the packetid filled at end
@@ -283,7 +285,23 @@
    }
 
    // Package protected ---------------------------------------------
+   protected int getEncodeSize()
+   {
+      return getHeaderEncodeSize() + getBodyEncodeSize();
+   }
 
+   protected int getHeaderEncodeSize()
+   {
+      return DataConstants.SIZE_INT * 2 +
+            DataConstants.SIZE_LONG * 3 +
+            DataConstants.SIZE_BYTE +
+            DataConstants.SIZE_BOOLEAN;
+   }
+
+   protected int getBodyEncodeSize()
+   {
+      return 0;
+   }
      protected String getParentString()
      {
         return "PACKET[type=" + type

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketsConfirmedMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketsConfirmedMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketsConfirmedMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * 
  * A PacketsConfirmedMessage
@@ -89,6 +91,10 @@
    }
    // Package protected ---------------------------------------------
 
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_INT;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerFlowCreditMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerFlowCreditMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerFlowCreditMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * 
  * A ProducerFlowCreditMessage
@@ -92,7 +94,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_INT;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerSendMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerSendMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerSendMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -24,8 +24,10 @@
 
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.Message;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+import org.jboss.messaging.util.DataConstants;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -84,11 +86,11 @@
    {
       if (clientMessage != null)
       {
-         clientMessage.encodeForTransport(this);
+         clientMessage.encodeForTransport(this, sendBodySeperately());
       }
       else
       {
-         serverMessage.encodeForTransport(this);
+         serverMessage.encodeForTransport(this, sendBodySeperately());
       }
    }
 
@@ -103,10 +105,54 @@
 
 
    // Package protected ---------------------------------------------
+   protected int getBodyEncodeSize()
+   {
+      Message message = clientMessage!=null?clientMessage:serverMessage;
+      int headerSize = getHeaderSize(message);
+      int sizeLeft = MAX_BUFFER_SIZE - getHeaderEncodeSize() - headerSize;
+      while(sizeLeft < 0)
+      {
+         sizeLeft += MAX_BUFFER_SIZE;
+      }
+      if(message.getBodySize() <= sizeLeft)
+      {
+         return headerSize + message.getBodySize();
+      }
+      else
+      {
+         return headerSize;
+      }
+   }
 
+   protected boolean sendBodySeperately()
+   {
+      Message message = clientMessage!=null?clientMessage:serverMessage;
+      int headerSize = getHeaderSize(message);
+      int sizeLeft = MAX_BUFFER_SIZE - getHeaderEncodeSize() - headerSize;
+      while(sizeLeft < 0)
+      {
+         sizeLeft += MAX_BUFFER_SIZE;
+      }
+      if(message.getBodySize() <= sizeLeft)
+      {
+         return false;
+      }
+      else
+      {
+         return true;
+      }
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------
-
+   private int getHeaderSize(Message message)
+   {
+      return getSimpleStringSize(message.getDestination()) +
+            DataConstants.SIZE_BYTE * 2 +
+            DataConstants.SIZE_BOOLEAN * 2 +
+            DataConstants.SIZE_LONG * 2 +
+            DataConstants.SIZE_INT +
+            message.getProperties().getEncodingSize();
+   }
    // Inner classes -------------------------------------------------
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReceiveMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReceiveMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReceiveMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -25,7 +25,9 @@
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.client.impl.ClientMessageImpl;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.Message;
 import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.util.DataConstants;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -106,7 +108,7 @@
    {
       putInt(deliveryCount);
       putLong(deliveryID);
-      serverMessage.encodeForTransport(this);
+      serverMessage.encodeForTransport(this, sendBodySeperately());
    }
    
    public void decodeBody()
@@ -122,10 +124,55 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      int headerSize = getHeaderSize(serverMessage);
+      int sizeLeft = MAX_BUFFER_SIZE - getHeaderEncodeSize() - headerSize;
+      while(sizeLeft < 0)
+      {
+         sizeLeft += MAX_BUFFER_SIZE;
+      }
+      if(serverMessage.getBodySize() <= sizeLeft)
+      {
+         return headerSize + getBodySize();
+      }
+      else
+      {
+         return headerSize;
+      }
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------
+    private int getHeaderSize(Message message)
+   {
+      return getSimpleStringSize(message.getDestination()) +
+            DataConstants.SIZE_BYTE * 2 +
+            DataConstants.SIZE_BOOLEAN * 2 +
+            DataConstants.SIZE_LONG * 2 +
+            DataConstants.SIZE_INT +
+            message.getProperties().getEncodingSize();
+   }
+   // Protected -----------------------------------------------------
+    protected boolean sendBodySeperately()
+   {
+      Message message = clientMessage!=null?clientMessage:serverMessage;
+      int headerSize = getHeaderSize(message);
+      int sizeLeft = MAX_BUFFER_SIZE - getHeaderEncodeSize() - headerSize;
+      while(sizeLeft < 0)
+      {
+         sizeLeft += MAX_BUFFER_SIZE;
+      }
+      if(message.getBodySize() <= sizeLeft)
+      {
+         return false;
+      }
+      else
+      {
+         return true;
+      }
+   }
+   // Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -99,7 +101,11 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_BOOLEAN  +
+             DataConstants.SIZE_LONG;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -116,6 +117,11 @@
    }
    
    // Package protected ---------------------------------------------
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN * 2 +
+              getSimpleStringSize(address);
+   }
 
    // Protected -----------------------------------------------------
 

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -74,5 +74,10 @@
       
       return super.equals(other) && this.address.equals(r.address);
    }
+
+   protected int getBodyEncodeSize()
+   {
+      return  getSimpleStringSize(address);
+   }
    
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 import java.util.ArrayList;
@@ -118,5 +119,10 @@
       
       return true;
    }
-   
+
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN * 2 +
+              getSimpleStringSize((SimpleString[]) queueNames.toArray());
+   }
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBrowserHasNextMessageResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBrowserHasNextMessageResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBrowserHasNextMessageResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -77,7 +79,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCancelMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCancelMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCancelMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -99,7 +101,11 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN +
+            DataConstants.SIZE_LONG;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -103,7 +103,11 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  getSimpleStringSize(queueName) +
+            getNullableSimpleStringSize(filterString);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -77,7 +79,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_LONG;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -141,7 +142,13 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_LONG +
+            DataConstants.SIZE_INT * 2 +
+            getSimpleStringSize(queueName) +
+            getNullableSimpleStringSize(filterString);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -103,7 +105,11 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_LONG +
+            DataConstants.SIZE_INT;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -131,7 +132,12 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_LONG +
+              getNullableSimpleStringSize(address) +
+            DataConstants.SIZE_INT  * 2;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -118,7 +120,11 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_LONG +
+            DataConstants.SIZE_INT * 2;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateQueueMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateQueueMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateQueueMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -137,7 +138,12 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  getSimpleStringSize(address, queueName) +
+            getNullableSimpleStringSize(filterString) +
+            DataConstants.SIZE_BOOLEAN * 2;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -92,7 +92,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return getSimpleStringSize(queueName);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -74,5 +74,9 @@
       
       return super.equals(other) && r.queueName.equals(this.queueName);
    }
-   
+
+   protected int getBodyEncodeSize()
+   {
+      return getSimpleStringSize(queueName);
+   }
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -154,5 +155,11 @@
                this.filterString == null ? r.filterString == null : this.filterString.equals(r.filterString) &&
                this.address == null ? r.address == null : this.address.equals(r.address);
    }
-   
+
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN * 2 +
+            DataConstants.SIZE_INT * 3 +
+            getNullableSimpleStringSize(filterString, address);
+   }
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,7 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -104,7 +105,11 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN +
+              getSimpleStringSize(address);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXACommitMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXACommitMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXACommitMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 import javax.transaction.xa.Xid;
 
 
@@ -102,7 +104,13 @@
    }
    
    // Package protected ---------------------------------------------
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN  +
+              getXidSize(xid);
+   }
 
+
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAEndMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAEndMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAEndMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 import javax.transaction.xa.Xid;
 
 
@@ -102,7 +104,11 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN  +
+              getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAForgetMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAForgetMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAForgetMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -84,7 +84,10 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 import javax.transaction.xa.Xid;
 import java.util.List;
 
@@ -110,7 +112,11 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_INT  +
+              getXidSize((Xid[]) xids.toArray());
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -82,7 +84,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_INT;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAJoinMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAJoinMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAJoinMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -84,7 +84,10 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAPrepareMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAPrepareMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAPrepareMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -84,7 +84,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -104,7 +106,12 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return DataConstants.SIZE_BOOLEAN  +
+            DataConstants.SIZE_INT +
+            getNullableStringSize(message);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResumeMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResumeMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResumeMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -84,7 +84,10 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXARollbackMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXARollbackMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXARollbackMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -84,7 +84,10 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -82,7 +84,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_INT;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -22,6 +22,8 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.DataConstants;
+
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -81,7 +83,10 @@
    }
    
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  DataConstants.SIZE_BOOLEAN;
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAStartMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAStartMessage.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAStartMessage.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -84,7 +84,10 @@
    }
 
    // Package protected ---------------------------------------------
-
+   protected int getBodyEncodeSize()
+   {
+      return  getXidSize(xid);
+   }
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingHandlerImplTest.java
===================================================================
--- branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingHandlerImplTest.java	2008-08-27 08:13:55 UTC (rev 4877)
+++ branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingHandlerImplTest.java	2008-08-27 10:43:32 UTC (rev 4878)
@@ -29,6 +29,7 @@
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
 import org.jboss.messaging.core.remoting.impl.RemotingHandlerImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.*;
+import org.jboss.messaging.core.remoting.spi.Connection;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
@@ -56,12 +57,14 @@
    private MessagingBuffer buff;
    private PacketDispatcher dispatcher;
    private ExecutorService executorService;
+   private Connection connection;
 
    protected void setUp() throws Exception
    {
       super.setUp();
       dispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
       executorService = EasyMock.createStrictMock(ExecutorService.class);
+      connection = EasyMock.createNiceMock(Connection.class);
       handler = new RemotingHandlerImpl(dispatcher, executorService);
       buff = new ByteBufferWrapper(ByteBuffer.allocate(1024));
    }
@@ -118,15 +121,17 @@
       
       final long connectionID = 123123;
       final int numTimes = 10;
-      
+
+      EasyMock.expect(connection.createBuffer(EasyMock.anyInt())).andReturn(buff);
       dispatcher.dispatch(connectionID, packet);
       EasyMock.expectLastCall().times(numTimes);
+
+      EasyMock.replay(dispatcher, connection);
       
-      //packet.encode(buff);
+      packet.encode(connection, 0);
       buff.getInt();
+
       
-      EasyMock.replay(dispatcher);
-      
       for (int i = 0; i < numTimes; i++)
       {
          handler.bufferReceived(connectionID, buff);
@@ -135,7 +140,7 @@
          buff.getInt();
       }
       
-      EasyMock.verify(dispatcher);
+      EasyMock.verify(dispatcher, connection);
    }
    
    public void testBufferReceivedWithExecutor() throws Exception
@@ -144,15 +149,16 @@
       
       final long connectionID = 123123;
       final int numTimes = 10;
-      
+
+      EasyMock.expect(connection.createBuffer(EasyMock.anyInt())).andReturn(buff);
       this.executorService.execute(EasyMock.isA(Runnable.class));
       EasyMock.expectLastCall().times(numTimes);
-      
-      //packet.encode(buff);
+
+      EasyMock.replay(dispatcher, connection);
+      packet.encode(connection, 0);
       buff.getInt();
+
       
-      EasyMock.replay(dispatcher);
-      
       for (int i = 0; i < numTimes; i++)
       {
          handler.bufferReceived(connectionID, buff);
@@ -161,7 +167,7 @@
          buff.getInt();
       }
       
-      EasyMock.verify(dispatcher);
+      EasyMock.verify(dispatcher, connection);
    }
    
    public void testExecutors() throws Exception




More information about the jboss-cvs-commits mailing list