[jboss-cvs] JBoss Messaging SVN: r4762 - in branches/Branch_Message_Chunking_new: examples/jms/src/org/jboss/jms/example and 10 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 1 04:41:23 EDT 2008


Author: ataylor
Date: 2008-08-01 04:41:23 -0400 (Fri, 01 Aug 2008)
New Revision: 4762

Removed:
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketAssembler.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragment.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentBuffer.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentCache.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/InMemoryPacketFragmentCache.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketAssemblerImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentBufferImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentImpl.java
Modified:
   branches/Branch_Message_Chunking_new/examples/jms/src/org/jboss/jms/example/QueueExample.java
   branches/Branch_Message_Chunking_new/messaging.ipr
   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/Packet.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/RemotingHandler.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingHandlerImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionResponseMessage.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/CreateConnectionRequest.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.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/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/src/main/org/jboss/messaging/jms/client/JBossMessage.java
   branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/util/TypedProperties.java
   branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingConnectionImplTest.java
   branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingHandlerImplTest.java
   branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionImplTest.java
   branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingHandlerImplTest.java
Log:
tidied up and removed packet fragment classes

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/examples/jms/src/org/jboss/jms/example/QueueExample.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -21,19 +21,11 @@
    */
 package org.jboss.jms.example;
 
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
+import org.jboss.messaging.core.logging.Logger;
+
+import javax.jms.*;
 import javax.naming.InitialContext;
 
-import org.jboss.messaging.core.logging.Logger;
-
 /**
  * A simple JMS Queue example that creates a producer and consumer on a queue and sends a message.
  *
@@ -52,20 +44,83 @@
          InitialContext initialContext = new InitialContext();
          Queue queue = (Queue) initialContext.lookup("/queue/testQueue");
          ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
-         
+
          connection = cf.createConnection();
          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         MessageProducer producer = session.createProducer(queue);
-         Message message = session.createTextMessage("This is a text message!");
-         
+         final MessageProducer producer = session.createProducer(queue);
+         final BytesMessage message = session.createBytesMessage();
+         byte[] bytes = new byte[1024];
+         for(int i = 0; i < 1024; i++)
+         {
+            bytes[i] = (byte) i;
+         }
+         byte[] newbytes = new byte[bytes.length];
+         message.writeBytes(bytes);
          log.info("sending message to queue");
          producer.send(message);
-         
+        /* new Thread(new Runnable()
+         {
+            public void run()
+            {
+
+               try
+               {
+                  producer.send(message);
+               }
+               catch (JMSException e)
+               {
+                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+               }
+            }
+         }).start();*/
+         /* new Thread(new Runnable()
+         {
+            public void run()
+            {
+
+               try
+               {
+                  producer.send(message);
+               }
+               catch (JMSException e)
+               {
+                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+               }
+            }
+         }).start();*/
+
          MessageConsumer messageConsumer = session.createConsumer(queue);
          connection.start();
-         TextMessage message2 = (TextMessage) messageConsumer.receive(5000);
+         BytesMessage message2 = (BytesMessage) messageConsumer.receive(50000000);
          log.info("message received from queue");
-         log.info("message = " + message2.getText());
+         message2.readBytes(newbytes);
+         //log.info("message = " + new String(newbytes));
+         for (int i = 0; i < newbytes.length; i++)
+         {
+            byte newbyte = newbytes[i];
+            System.out.print(newbyte);
+            System.out.print(" = ");
+            System.out.println(bytes[i]);
+            if(bytes[i] != newbyte)
+            {
+               throw new RuntimeException(i+"");
+            }
+         }
+         /*message2 = (BytesMessage) messageConsumer.receive(50000000);
+         log.info("message received from queue");
+         message2.readBytes(newbytes);
+         //log.info("message = " + new String(newbytes));
+         for (int i = 0; i < newbytes.length; i++)
+         {
+            byte newbyte = newbytes[i];
+            System.out.print(newbyte);
+            System.out.print(" = ");
+            System.out.println(bytes[i]);
+            if(bytes[i] != newbyte)
+            {
+               throw new RuntimeException(i+"");
+            }
+         }*/
       }
       catch (Exception e)
       {

Modified: branches/Branch_Message_Chunking_new/messaging.ipr
===================================================================
--- branches/Branch_Message_Chunking_new/messaging.ipr	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/messaging.ipr	2008-08-01 08:41:23 UTC (rev 4762)
@@ -463,12 +463,13 @@
         <root url="jar:///home/andy/devtools/apache-ant-1.7.0/lib/ant-junit.jar!/" />
         <root url="jar:///home/andy/devtools/apache-ant-1.7.0/lib/ant.jar!/" />
         <root url="jar://$PROJECT_DIR$/thirdparty/apache-mina/lib/mina-core-2.0.0-M3-20080730.120633-1.jar!/" />
+        <root url="file://$PROJECT_DIR$/examples/jms/config" />
       </CLASSES>
       <JAVADOC />
       <SOURCES>
         <root url="jar://$PROJECT_DIR$/thirdparty/jboss/jnpserver/lib/jnpserver-sources.jar!/" />
-        <root url="jar://$PROJECT_DIR$/thirdparty/apache-mina/lib/mina-core-2.0.0-M2-20080520.004618-19-sources.jar!/" />
       </SOURCES>
+      <jarDirectory url="file://$PROJECT_DIR$/examples/jms/config" recursive="false" />
       <jarDirectory url="file://$PROJECT_DIR$/src/etc" recursive="false" />
       <jarDirectory url="file://$PROJECT_DIR$/tests/etc" recursive="false" />
       <jarDirectory url="file://$PROJECT_DIR$/tests/jms-tests/etc" recursive="false" />

Modified: branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml
===================================================================
--- branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/config/jbm-configuration.xml	2008-08-01 08:41:23 UTC (rev 4762)
@@ -25,7 +25,7 @@
       <remoting-port>5400</remoting-port>
 
       <!--  call timeout in milliseconds -->
-      <remoting-call-timeout>5000</remoting-call-timeout>
+      <remoting-call-timeout>5000000</remoting-call-timeout>
 
       <!-- true to enable invm communication when the client and the server are in the same JVM.     -->
       <remoting-enable-invm-optimisation>true</remoting-enable-invm-optimisation>
@@ -46,7 +46,7 @@
 
       <!-- The interval to send a ping message to send to the client/server to make sure it is still alive.-->
       <!-- Set to 0 if you want to disable this functionality-->
-      <remoting-ping-interval>10000</remoting-ping-interval>
+      <remoting-ping-interval>0</remoting-ping-interval>
 
       <!--How long to wait for a returning pong after sending a ping message to a client/server.-->
       <!-- If no pong is received after this time resources are cleaned up-->

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/Message.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,12 +22,14 @@
 
 package org.jboss.messaging.core.message;
 
-import java.util.Set;
-
 import org.jboss.messaging.core.journal.EncodingSupport;
 import org.jboss.messaging.core.remoting.MessagingBuffer;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.util.SimpleString;
+import org.jboss.messaging.util.TypedProperties;
 
+import java.util.Set;
+
 /**
  * A message is a routable instance that has a payload.
  * 
@@ -68,6 +70,10 @@
    
    int getEncodeSize();
 
+   void encode(Packet packet);
+
+   void decode(Packet packet);
+
    void encode(MessagingBuffer buffer);
    
    void decode(MessagingBuffer buffer);
@@ -103,6 +109,8 @@
    boolean containsProperty(SimpleString key);
    
    Set<SimpleString> getPropertyNames();
+
+   TypedProperties getProperties();
    
    // Body
    // ---------------------------------------------------------------------------------

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,19 +22,16 @@
 
 package org.jboss.messaging.core.message.impl;
 
-import static org.jboss.messaging.util.DataConstants.SIZE_BOOLEAN;
-import static org.jboss.messaging.util.DataConstants.SIZE_BYTE;
-import static org.jboss.messaging.util.DataConstants.SIZE_INT;
-import static org.jboss.messaging.util.DataConstants.SIZE_LONG;
-
-import java.util.Set;
-
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.message.Message;
 import org.jboss.messaging.core.remoting.MessagingBuffer;
+import org.jboss.messaging.core.remoting.Packet;
+import static org.jboss.messaging.util.DataConstants.*;
 import org.jboss.messaging.util.SimpleString;
 import org.jboss.messaging.util.TypedProperties;
 
+import java.util.Set;
+
 /**
  * A concrete implementation of a message
  *
@@ -121,6 +118,17 @@
    }
 
    // Message implementation ----------------------------------------
+    public void encode(Packet buff)
+   {
+      buff.putSimpleString(destination);
+      buff.putByte(type);
+      buff.putBoolean(durable);
+      buff.putLong(expiration);
+      buff.putLong(timestamp);
+      buff.putByte(priority);
+      properties.encode(buff);
+      buff.putBody(body);
+   }
 
    public void encode(MessagingBuffer buff)
    {
@@ -147,6 +155,19 @@
       /* BodySize and Body */ SIZE_INT + body.limit();
    }
 
+   public void decode(final Packet buffer)
+   {
+      destination = buffer.getSimpleString();
+      type = buffer.getByte();
+      durable = buffer.getBoolean();
+      expiration = buffer.getLong();
+      timestamp = buffer.getLong();
+      priority = buffer.getByte();
+
+      properties.decode(buffer);
+      body = buffer.getBodyType();
+   }
+
    public void decode(final MessagingBuffer buffer)
    {
       destination = buffer.getSimpleString();
@@ -298,7 +319,12 @@
    {
       return properties.getPropertyNames();
    }
-   
+
+   public TypedProperties getProperties()
+   {
+      return properties;
+   }
+
    // Body
    // -------------------------------------------------------------------------------------
    

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/Packet.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/Packet.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/Packet.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,11 @@
 
 package org.jboss.messaging.core.remoting;
 
+import org.jboss.messaging.util.SimpleString;
 
+import java.util.List;
+
+
 /**
  * 
  * A Packet
@@ -55,7 +59,79 @@
    
    void normalize(Packet other);
 
-   void encode(MessagingBuffer buffer);
+   void encode(MessagingBuffer buffer, int packetId);
       
-   void decode(MessagingBuffer buffer);
+   void decode();
+
+   void putFloat(float val);
+
+   void putInt(int i);
+
+   void putByte(byte b);
+
+   void putLong(long l);
+
+   void putBoolean(boolean b);
+
+   void putNullableString(String nullableString);
+
+   void putSimpleString(SimpleString string);
+
+   void putNullableSimpleString(SimpleString string);
+
+   void putBytes(byte[] bytes, int i, int i1);
+
+   void putBytes(byte[] bytes);
+
+   void putShort(short val);
+
+   void putDouble(double val);
+
+   void putChar(char val);
+
+   void putUTF(String str);
+
+   void putString(String string);
+
+   String getString();
+
+   void getBytes(byte[] value, int i, int read);
+
+   String getUTF() throws Exception;
+
+   int getInt();
+
+   long getLong();
+
+   short getShort();
+
+   boolean getBoolean();
+
+   String getNullableString();
+
+   SimpleString getSimpleString();
+
+   SimpleString getNullableSimpleString();
+
+   byte getByte();
+
+   void getBytes(byte[] data);
+
+   float getFloat();
+
+   double getDouble();
+
+   char getChar();
+
+   short getUnsignedByte();
+
+   int getUnsignedShort();
+
+   void putBody(MessagingBuffer body);
+
+   List<MessagingBuffer> getBuffers();
+
+   void addBuffer(MessagingBuffer buffer, int packetLength);
+
+   MessagingBuffer getBodyType();
 }

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketAssembler.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketAssembler.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketAssembler.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,19 +0,0 @@
-package org.jboss.messaging.core.remoting;
-
-import org.jboss.messaging.core.remoting.spi.Connection;
-
-/**
- * Assembles and dissasembles packets to and from PAcket Fragments before sending and receiving.
- * 
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public interface PacketAssembler
-{
-   Packet assemble(MessagingBuffer buffer, RemotingHandler handler, long connectionID) throws Exception;
-
-   void disAssemble(MessagingBuffer buffer, Connection connection, Packet message);
-
-   int getInitialPacketFragmentSize();
-
-   int getPacketFragmentSize();
-}

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragment.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragment.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragment.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,88 +0,0 @@
-package org.jboss.messaging.core.remoting;
-
-
-/**
- * A Packet Fragment. Holds info and the contents of a fragment of an encoded Packet.
- * 
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public interface PacketFragment
-{
-   int getPacketId();
-
-   int getCorrelationId();
-
-   int getLength();
-
-   boolean isLastPacket();
-
-   int getEndPosition();
-
-   boolean checkSpace(int size);
-
-   boolean hasReadSpace(int size);
-
-   void putFloat(float val);
-
-   void putInt(int i);
-
-   void putByte(byte b);
-
-   void putLong(long l);
-
-   void putBoolean(boolean b);
-
-   void putBytes(byte[] bytes, int i, int i1);
-
-   void putDouble(double val);
-
-   void putShort(short val);
-
-   void putChar(char val);
-
-   int getInt();
-
-   long getLong();
-
-   short getShort();
-
-   boolean getBoolean();
-
-   byte getByte();
-
-   void getBytes(byte[] data);
-
-   void getBytes(byte[] data, int read, int left);
-
-   float getFloat();
-
-   double getDouble();
-
-   char getChar();
-
-   short getUnsignedByte();
-
-   int getBodyLength();
-
-   void setBodyLength(int bodyLength);
-
-   void writeHeaders();
-
-   int remaining();
-
-   int limit();
-
-   PacketFragment createNextPacketFragment(int packetFragmentSize);
-
-   void putBoolean(int actualPos, boolean val);
-
-   void putInt(int actualPos, int val);
-
-   void rewind();
-
-   void flip();
-
-   void position(int position);
-
-   MessagingBuffer getMessagingBuffer();
-}

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentBuffer.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentBuffer.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentBuffer.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * 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.remoting;
-
-import java.util.List;
-
-/**
- * Extends a MessagingBuffer to allow acces to th eunderlying PAcket Fragments.
- * 
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public interface PacketFragmentBuffer extends MessagingBuffer
-{
-   List<PacketFragment> getPacketFragments();
-
-   void prepare();
-}

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentCache.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentCache.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/PacketFragmentCache.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,15 +0,0 @@
-package org.jboss.messaging.core.remoting;
-
-/**
- * Used to cache the contents of Packet Fragments until needed.
- * 
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public interface PacketFragmentCache
-{
-   void cache(MessagingBuffer buffer, int length, long connectionID, int packetId, int correlationId);
-
-   MessagingBuffer retrieve(int length, long connectionID, int packetId, int correlationId);
-
-   void clear(long connectionID);
-}

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/RemotingHandler.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/RemotingHandler.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/RemotingHandler.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -41,6 +41,4 @@
    Set<Long> scanForFailedConnections(long expirePeriod);
    
    void removeLastPing(long connectionID);
-
-   Packet decode(final long connectionID, final MessagingBuffer in) throws Exception;
 }

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -84,13 +84,10 @@
       }
       else
       {
-         PacketFragmentCache packetFragmentCache = new InMemoryPacketFragmentCache();
 
-         PacketAssembler assembler = new PacketAssemblerImpl(connectionParams.getInitialPacketFragmentSize(), connectionParams.getPacketFragmentSize(), packetFragmentCache);
-
          PacketDispatcher dispatcher = new PacketDispatcherImpl(null);
          
-         RemotingHandler handler = new RemotingHandlerImpl(dispatcher, null, assembler);
+         RemotingHandler handler = new RemotingHandlerImpl(dispatcher, null);
          
          Connector connector = createConnector(location, connectionParams, handler, this);
          
@@ -108,12 +105,12 @@
          if (pingInterval != -1)
          {
             connection = new RemotingConnectionImpl(tc, dispatcher, location,
-               connectionParams.getCallTimeout(), connectionParams.getPingInterval(), pingExecutor, assembler);
+               connectionParams.getCallTimeout(), connectionParams.getPingInterval(), pingExecutor);
          }
          else
          {
             connection = new RemotingConnectionImpl(tc, dispatcher, location,
-                  connectionParams.getCallTimeout(), assembler);
+                  connectionParams.getCallTimeout());
          }
 
          remotingConnections.put(tc.getID(), connection);

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/InMemoryPacketFragmentCache.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/InMemoryPacketFragmentCache.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/InMemoryPacketFragmentCache.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * 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.remoting.impl;
-
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-import org.jboss.messaging.core.remoting.PacketFragmentCache;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A simple in memory cache for message buffers.
- *
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public class InMemoryPacketFragmentCache implements PacketFragmentCache
-{
-   Map<Long, Map<Integer, List<MessagingBuffer>>> cache = new HashMap<Long, Map<Integer, List<MessagingBuffer>>>();
-
-   /**
-    * adds a buffer to a list for later use. We make an assumption that theunderlying bytes don't get modified before
-    * they are needed.
-    *
-    * @param buffer the buffer to cache.
-    * @param length the length of the buffer.
-    * @param connectionID the connection id.
-    * @param packetId the Packet ID.
-    * @param correlationID The correlation ID.
-    */
-   public void cache(MessagingBuffer buffer, int length, long connectionID, int packetId, int correlationID)
-   {
-      getByteList(connectionID, packetId).add(buffer);
-   }
-
-   /**
-    * retrieves the first buffer from the list and removes it.
-    * @param length The length of the buffer.
-    * @param connectionID The Connection ID.
-    * @param packetId the Packet ID.
-    * @param correlationId The Correlation ID.
-    * @return the appropriate Messaging Buffer.
-    */
-   public MessagingBuffer retrieve(int length, long connectionID, int packetId, int correlationId)
-   {
-      List<MessagingBuffer> buffers = getByteList(connectionID, packetId);
-      MessagingBuffer buffer = buffers.remove(0);
-      if(buffers.isEmpty())
-      {
-         Map<Integer, List<MessagingBuffer>> sessionMap = cache.get(connectionID);
-         sessionMap.remove(packetId);
-         if(sessionMap.isEmpty())
-         {
-            cache.remove(connectionID);
-         }
-      }
-      return buffer;
-   }
-
-   /**
-    * clears the cache for a specific Connection.
-    * @param connectionID The connection ID.
-    */
-   public void clear(long connectionID)
-   {
-      cache.remove(connectionID);
-   }
-
-
-   protected List<MessagingBuffer> getByteList(long sessionId, int packetId)
-   {
-      if(cache.get(sessionId) == null)
-      {
-         cache.put(sessionId, new HashMap<Integer, List<MessagingBuffer>>());
-      }
-      if(cache.get(sessionId).get(packetId) == null)
-      {
-         cache.get(sessionId).put(packetId, new ArrayList<MessagingBuffer>());
-      }
-      return cache.get(sessionId).get(packetId);
-   }
-
-}

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketAssemblerImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketAssemblerImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketAssemblerImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,161 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * 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.remoting.impl;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.*;
-import org.jboss.messaging.core.remoting.spi.Connection;
-import org.jboss.messaging.util.DataConstants;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public class PacketAssemblerImpl implements PacketAssembler
-{
-   private static final Logger log = Logger.getLogger(PacketAssemblerImpl.class);
-   Map<Long, Map<Integer, List<PacketFragment>>> allFragments = new HashMap<Long, Map<Integer, List<PacketFragment>>>();
-   private AtomicInteger packetId = new AtomicInteger(0);
-   private int packetFragmentSize;
-   private boolean useMessageChunking = false;
-   private PacketFragmentCache packetFragmentCache;
-   private int initialPacketFragmentSize;
-   private List<Float> longs = new ArrayList<Float>();
-
-   public PacketAssemblerImpl(final int initialPacketFragmentSize,final int packetFragmentSize,final PacketFragmentCache packetFragmentCache)
-   {
-      this.packetFragmentSize = packetFragmentSize;
-      this.initialPacketFragmentSize = initialPacketFragmentSize;
-      useMessageChunking = this.packetFragmentSize > 0;
-      this.packetFragmentCache = packetFragmentCache;
-   }
-
-   public Packet assemble(final MessagingBuffer buffer,final RemotingHandler handler,final long connectionID) throws Exception
-   {
-      int length = buffer.getInt();
-      if (useMessageChunking)
-      {
-         return assembleMulti(buffer, handler, connectionID, length);
-      }
-      else
-      {
-         return assembleSingle(buffer, handler, connectionID, length);
-      }
-   }
-
-
-   public void disAssemble(final MessagingBuffer buffer, final Connection connection, final Packet message)
-   {
-      if (useMessageChunking)
-      {
-         disasembleMulti(buffer, connection, message);
-      }
-      else
-      {
-         disasembleSingle(buffer, connection, message);
-      }
-   }
-
-   public int getInitialPacketFragmentSize()
-   {
-      return initialPacketFragmentSize;
-   }
-
-   public int getPacketFragmentSize()
-   {
-      return packetFragmentSize;
-   }
-
-   private List<PacketFragment> getFragments(final long id, final int packetId)
-   {
-      if(allFragments.get(id) == null)
-      {
-         allFragments.put(id, new HashMap<Integer, List<PacketFragment>>());
-      }
-      if(allFragments.get(id).get(packetId) == null)
-      {
-         allFragments.get(id).put(packetId, new ArrayList<PacketFragment>());
-      }
-      return allFragments.get(id).get(packetId);
-   }
-
-
-   private void disasembleMulti(final MessagingBuffer buffer, final Connection connection, final Packet message)
-   {
-      PacketFragmentBuffer buff = new PacketFragmentBufferImpl(packetId.getAndIncrement(), buffer, packetFragmentSize);
-      message.encode(buff);
-      buff.prepare();
-      buff.flip();
-      for (PacketFragment packetFragment : buff.getPacketFragments())
-      {
-         connection.write(packetFragment.getMessagingBuffer());
-      }
-   }
-
-   private void disasembleSingle(MessagingBuffer buffer, Connection connection, Packet message)
-   {
-      buffer.putInt(-1);
-      message.encode(buffer);
-      //The length doesn't include the actual length byte
-      int len = buffer.position() - DataConstants.SIZE_INT;
-      buffer.putInt(0, len);
-      buffer.flip();
-      connection.write(buffer);
-   }
-
-   private Packet assembleMulti(final MessagingBuffer buffer, final RemotingHandler handler, final long connectionID, final int length)
-         throws Exception
-   {
-      boolean lastPacket = buffer.getBoolean();
-      int packetId = buffer.getInt();
-      int correlationId = buffer.getInt();
-
-      if(lastPacket)
-      {
-         PacketFragmentImpl fragment = new PacketFragmentImpl(packetId, lastPacket, correlationId, length, buffer);
-         getFragments(connectionID, fragment.getPacketId()).add(fragment);
-         List<PacketFragment> fragments = allFragments.get(connectionID).remove(fragment.getPacketId());
-         PacketFragmentBuffer buff = new PacketFragmentBufferImpl(fragments, packetFragmentSize);
-         return handler.decode(connectionID, buff);
-      }
-      else
-      {
-         //if we are part of a multi part packet then we need to be cached for later use
-         //PacketFragmentImpl fragment = new PacketFragmentImpl(packetId, lastPacket, correlationId, length, packetFragmentCache,connectionID);
-         PacketFragmentImpl fragment = new PacketFragmentImpl(packetId, lastPacket, correlationId, length, buffer);
-         getFragments(connectionID, fragment.getPacketId()).add(fragment);
-         //packetFragmentCache.cache(buffer, length - 9, connectionID, packetId, correlationId);
-         return null;
-      }
-   }
-
-   private Packet assembleSingle(final MessagingBuffer buffer, final RemotingHandler handler, final long connectionID, final int length)
-         throws Exception
-   {
-      return handler.decode(connectionID, buffer);
-   }
-}

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentBufferImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentBufferImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentBufferImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,532 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * 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.remoting.impl;
-
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-import org.jboss.messaging.core.remoting.PacketFragment;
-import org.jboss.messaging.core.remoting.PacketFragmentBuffer;
-import static org.jboss.messaging.util.DataConstants.*;
-import org.jboss.messaging.util.SimpleString;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A MessagingBuffer that can be used to break up the buffers into smaller pieces.
- *
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public class PacketFragmentBufferImpl implements PacketFragmentBuffer
-{
-
-   private static final Charset utf8 = Charset.forName("UTF-8");
-
-   private List<PacketFragment> packetFragments;
-   private int currentPos = 0;
-   private int correlationId = 0;
-   private int packetFragmentSize;
-   private int position = 0;
-
-   public PacketFragmentBufferImpl(int packetId, MessagingBuffer buffer, int packetFragmentSize)
-   {
-      packetFragments = new ArrayList<PacketFragment>();
-      packetFragments.add(new PacketFragmentImpl(packetId, correlationId++, buffer));
-      this.packetFragmentSize = packetFragmentSize;
-   }
-
-   public PacketFragmentBufferImpl(List<PacketFragment> packetFragments, int packetFragmentSize)
-   {
-      if(packetFragments == null || packetFragments.size() == 0)
-      {
-         throw new IllegalArgumentException("packet fragments must not be null or empty");
-      }
-      this.packetFragments = packetFragments;
-      currentPos = 0;
-      this.packetFragmentSize = packetFragmentSize;
-   }
-
-   public void putFloat(float val)
-   {
-      checkWriteSpace(SIZE_FLOAT);
-      getCurrentFragment().putFloat(val);
-      position += SIZE_FLOAT;
-   }
-
-   public void putInt(int i)
-   {
-      checkWriteSpace(SIZE_INT);
-      getCurrentFragment().putInt(i);
-      position += SIZE_INT;
-   }
-
-   public void putByte(byte b)
-   {
-      checkWriteSpace(SIZE_BYTE);
-      getCurrentFragment().putByte(b);
-      position += SIZE_BYTE;
-   }
-
-   public void putLong(long l)
-   {
-      checkWriteSpace(SIZE_LONG);
-      getCurrentFragment().putLong(l);
-      position += SIZE_LONG;
-   }
-
-   public void putBoolean(boolean b)
-   {
-      checkWriteSpace(SIZE_BOOLEAN);
-      getCurrentFragment().putBoolean(b);
-      position += SIZE_BOOLEAN;
-   }
-
-   public void putNullableString(String nullableString)
-   {
-      if (nullableString == null)
-		{
-			putByte(NULL);
-		}
-		else
-		{
-			putByte(NOT_NULL);
-
-			putString(nullableString);
-		}
-   }
-
-   public void putSimpleString(SimpleString string)
-   {
-      byte[] data = string.getData();
-
-   	putInt(data.length);
-   	putBytes(data);
-   }
-
-   public void putNullableSimpleString(SimpleString string)
-   {
-      if (string == null)
-   	{
-   		putByte(NULL);
-   	}
-   	else
-   	{
-   	   putByte(NOT_NULL);
-   		putSimpleString(string);
-   	}
-   }
-
-   public void putBytes(byte[] bytes, int i, int i1)
-   {
-      if(getCurrentFragment().checkSpace(i1 - i))
-      {
-         getCurrentFragment().putBytes(bytes, i, i1);
-      }
-      else
-      {
-         int size = bytes.length;
-         int written = 0;
-         while(written < i1)
-         {
-            int left = getCurrentFragment().remaining();
-            int towrite = left + written > i1?i1 - written:left;
-            getCurrentFragment().putBytes(bytes, i, towrite);
-            written+=towrite;
-            i += left;
-            if(written < i1)
-            {
-               setNextFragment();
-            }
-         }
-      }
-      position += i1;
-   }
-
-   public void putBytes(byte[] bytes)
-   {
-      putBytes(bytes, 0, bytes.length);
-   }
-
-   public void putShort(short val)
-   {
-      checkWriteSpace(SIZE_SHORT);
-      getCurrentFragment().putShort(val);
-      position += SIZE_SHORT;
-   }
-
-   public void putDouble(double val)
-   {
-      checkWriteSpace(SIZE_DOUBLE);
-      getCurrentFragment().putDouble(val);
-      position += SIZE_DOUBLE;
-   }
-
-   public void putChar(char val)
-   {
-      checkWriteSpace(SIZE_CHAR);
-      getCurrentFragment().putChar(val);
-      position += SIZE_CHAR;
-   }
-
-   public void putUTF(String str)
-   {
-      //TODO This is quite inefficient - can be improved using a method similar to what MINA IOBuffer does
-		//(putPrefixedString)
-		ByteBuffer bb = utf8.encode(str);
-   	putInt(bb.limit() - bb.position());
-   	putBytes(bb.array());
-   }
-
-   public void putBoolean(int pos, boolean val)
-   {
-      int currentpos = 0;
-      for (PacketFragment packetFragment : packetFragments)
-      {
-         if(pos < packetFragment.getBodyLength())
-         {
-            packetFragment.putBoolean(pos - currentpos, val);
-            return;
-         }
-         currentpos += packetFragment.getBodyLength();
-      }
-      throw new IndexOutOfBoundsException();
-   }
-
-   public void putInt(int pos, int val)
-   {
-      int currentpos = 0;
-      for (PacketFragment packetFragment : packetFragments)
-      {
-         if(pos < packetFragment.getBodyLength())
-         {
-            packetFragment.putInt(pos - currentpos, val);
-            return;
-         }
-         currentpos += packetFragment.getBodyLength();
-      }
-      throw new IndexOutOfBoundsException();
-   }
-
-
-   public void putString(String string)
-   {
-      putInt(string.length());
-
-		for (int i = 0; i < string.length(); i++)
-		{
-			putChar(string.charAt(i));
-		}
-   }
-
-   public byte[] array()
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public int capacity()
-   {
-      return 0;
-   }
-
-   public void limit(int limit)
-   {
-
-   }
-
-   public void position(int position)
-   {
-      int currentpos = 0;
-      for (int i = 0; i < packetFragments.size(); i++)
-      {
-         PacketFragment packetFragment = packetFragments.get(i);
-         currentpos += packetFragment.getBodyLength();
-         if (position < packetFragment.getBodyLength())
-         {
-            currentpos = i;
-            this.position = position;
-            packetFragment.position(position - currentpos);
-            return;
-         }
-      }
-   }
-
-   public int position()
-   {
-      return position;
-   }
-
-   public MessagingBuffer slice()
-   {
-      return null;
-   }
-
-   public MessagingBuffer createNewBuffer(int len)
-   {
-      return getCurrentFragment().getMessagingBuffer().createNewBuffer(len);
-   }
-
-
-   public String getString()
-   {
-      int len = getInt();
-
-   	char[] chars = new char[len];
-
-      for (int i = 0; i < len; i++)
-      {
-      	chars[i] = getChar();
-      }
-
-      return new String(chars);
-   }
-
-   public void getBytes(byte[] value, int i, int read)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public String getUTF() throws Exception
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public void flip()
-   {
-      for (PacketFragment packetFragment : packetFragments)
-      {
-         packetFragment.flip();
-      }
-      currentPos = 0;
-      position = 0;
-   }
-
-   public void rewind()
-   {
-      for (PacketFragment packetFragment : packetFragments)
-      {
-         packetFragment.rewind();
-      }
-      currentPos = 0;
-      position = 0;
-   }
-
-
-   public int getInt()
-   {
-      checkReadSpace(SIZE_INT);
-      position += SIZE_INT;
-      return getCurrentFragment().getInt();
-   }
-
-   public long getLong()
-   {
-      checkReadSpace(SIZE_LONG);
-      position += SIZE_LONG;
-      return getCurrentFragment().getLong();
-   }
-
-   public short getShort()
-   {
-      checkReadSpace(SIZE_SHORT);
-      position += SIZE_SHORT;
-      return getCurrentFragment().getShort();
-   }
-
-   public boolean getBoolean()
-   {
-      checkReadSpace(SIZE_BOOLEAN);
-      position += SIZE_BOOLEAN;
-      return getCurrentFragment().getBoolean();
-   }
-
-   public String getNullableString()
-   {
-      byte check = getByte();
-
-		if (check == NULL)
-		{
-			return null;
-		}
-		else
-		{
-			return getString();
-		}
-   }
-
-   public SimpleString getSimpleString()
-   {
-      int len = getInt();
-
-   	byte[] data = new byte[len];
-   	getBytes(data);
-
-   	return new SimpleString(data);
-   }
-
-    public SimpleString getNullableSimpleString()
-   {
-      int b = getByte();
-   	if (b == NULL)
-   	{
-   	   return null;
-   	}
-   	else
-   	{
-         return getSimpleString();
-   	}
-   }
-
-   public byte getByte()
-   {
-      checkReadSpace(SIZE_BYTE);
-      position += SIZE_BYTE;
-      return getCurrentFragment().getByte();
-   }
-
-   public void getBytes(byte[] data)
-   {
-      int left = getCurrentFragment().remaining();
-      if(data.length <= left)
-      {
-         getCurrentFragment().getBytes(data);
-      }
-      else
-      {
-         int size = data.length;
-         int read = 0;
-         while (read < size)
-         {
-            left = getCurrentFragment().remaining() <= (size - read)? getCurrentFragment().remaining():size - read;
-
-            getCurrentFragment().getBytes(data, read, left);
-            read += left;
-            if(read < size)
-            {
-               currentPos++;
-            }
-
-         }
-
-      }
-      position += data.length;
-   }
-
-
-   public float getFloat()
-   {
-      checkReadSpace(SIZE_FLOAT);
-      position += SIZE_FLOAT;
-      return getCurrentFragment().getFloat();
-   }
-
-   public double getDouble()
-   {
-      checkReadSpace(SIZE_DOUBLE);
-      position += SIZE_DOUBLE;
-      return getCurrentFragment().getDouble();
-   }
-
-   public char getChar()
-   {
-      checkReadSpace(SIZE_CHAR);
-      position += SIZE_CHAR;
-      return getCurrentFragment().getChar();
-   }
-
-   public List<PacketFragment> getPacketFragments()
-   {
-      return packetFragments;
-   }
-
-   public void prepare()
-   {
-      for (PacketFragment packetFragment : packetFragments)
-      {
-         packetFragment.writeHeaders();
-      }
-   }
-
-   public short getUnsignedByte()
-   {
-      checkReadSpace(SIZE_SHORT);
-      return getCurrentFragment().getUnsignedByte();
-   }
-
-   public int getUnsignedShort()
-   {
-     checkReadSpace(SIZE_INT);
-      return getCurrentFragment().getUnsignedByte();
-   }
-
-   public int remaining()
-   {
-      return getCurrentFragment().remaining();
-   }
-
-   public int limit()
-   {
-      int currentLimit = 0;
-      for (PacketFragment packetFragment : packetFragments)
-      {
-         currentLimit += packetFragment.limit();
-      }
-      return currentLimit;
-   }
-
-    public Object getUnderlyingBuffer()
-    {
-        return null;
-    }
-
-    // Private -------------------------------------------------------
-
-   private void checkReadSpace(int size)
-   {
-      if(!getCurrentFragment().checkSpace(size))
-      {
-         currentPos++;
-      }
-   }
-
-   private void checkWriteSpace(int size)
-   {
-      if(!getCurrentFragment().checkSpace(size))
-      {
-         setNextFragment();
-      }
-   }
-
-   private void setNextFragment()
-   {
-      packetFragments.add(getCurrentFragment().createNextPacketFragment(packetFragmentSize));
-      currentPos++;
-   }
-
-
-   private PacketFragment getCurrentFragment()
-   {
-      return packetFragments.get(currentPos);
-   }
-
-
-}

Deleted: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/PacketFragmentImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -1,295 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * 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.remoting.impl;
-
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-import org.jboss.messaging.core.remoting.PacketFragment;
-import org.jboss.messaging.core.remoting.PacketFragmentCache;
-import static org.jboss.messaging.util.DataConstants.*;
-
-/**
- * A fragment of a full packet that holds a portion of a full message within a buffer.
- *
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public class PacketFragmentImpl implements PacketFragment
-{
-   private int bodyLength = 0;
-   private int packetId;
-   private int correlationId;
-   private boolean lastPacket;
-   private long sessionId;
-   private int dataStartPosition = -1;
-   private MessagingBuffer messagingBuffer;
-   private PacketFragmentCache packetFragmentCache;
-   private static final int HEADER_SIZE = (SIZE_INT * 3) + SIZE_BOOLEAN;
-
-   public PacketFragmentImpl(int packetId, boolean lastPacket, int correlationId, int length, PacketFragmentCache packetFragmentCache, long id)
-   {
-      this.packetId = packetId;
-      this.lastPacket = lastPacket;
-      this.correlationId = correlationId;
-      this.packetFragmentCache = packetFragmentCache;
-      this.bodyLength = length - HEADER_SIZE;
-      this.sessionId = id;
-      dataStartPosition = 0;
-   }
-
-    public PacketFragmentImpl(int packetId, boolean lastPacket, int correlationId, int length, MessagingBuffer messagingBuffer)
-   {
-      this.packetId = packetId;
-      this.lastPacket = lastPacket;
-      this.correlationId = correlationId;
-      this.bodyLength = length - HEADER_SIZE;
-      this.messagingBuffer = messagingBuffer;
-      dataStartPosition = messagingBuffer.position();
-   }
-
-   public PacketFragmentImpl(int packetId, int correlationId, MessagingBuffer messagingBuffer)
-   {
-      this.packetId = packetId;
-      this.lastPacket = true;
-      this.correlationId = correlationId;
-      this.messagingBuffer = messagingBuffer;
-      messagingBuffer.putInt(-1);
-      messagingBuffer.putBoolean(true);
-      messagingBuffer.putInt(packetId);
-      messagingBuffer.putInt(correlationId);
-      dataStartPosition = messagingBuffer.position();
-   }
-
-   public int getPacketId()
-   {
-      return packetId;
-   }
-
-   public int getCorrelationId()
-   {
-      return correlationId;
-   }
-
-   public int getLength()
-   {
-      return bodyLength + HEADER_SIZE;
-   }
-
-   public boolean isLastPacket()
-   {
-      return lastPacket;
-   }
-
-   public MessagingBuffer getMessagingBuffer()
-   {
-      if(messagingBuffer == null)
-      {
-         messagingBuffer = packetFragmentCache.retrieve(getLength(), sessionId, packetId, correlationId);
-      }
-      return messagingBuffer;
-   }
-
-   public int getEndPosition()
-   {
-      return dataStartPosition + getLength() - HEADER_SIZE;
-   }
-
-   public boolean checkSpace(int size)
-   {
-      int left = getMessagingBuffer().limit() - getMessagingBuffer().position();
-      return size<=left;
-   }
-
-   public boolean hasReadSpace(int size)
-   {
-      return getMessagingBuffer().position() + size <= getMessagingBuffer().limit();
-   }
-
-   public void putFloat(float val)
-   {
-      getMessagingBuffer().putFloat(val);
-      bodyLength += SIZE_FLOAT;
-   }
-
-   public void putInt(int i)
-   {
-      getMessagingBuffer().putInt(i);
-      bodyLength += SIZE_INT;
-   }
-
-   public void putByte(byte b)
-   {
-      getMessagingBuffer().putByte(b);
-      bodyLength += SIZE_BYTE;
-   }
-
-   public void putLong(long l)
-   {
-      getMessagingBuffer().putLong(l);
-      bodyLength += SIZE_LONG;
-   }
-
-   public void putBytes(byte[] bytes, int i, int i1)
-   {
-      getMessagingBuffer().putBytes(bytes, i, i1);
-      bodyLength += i1;
-   }
-
-   public void putDouble(double val)
-   {
-      getMessagingBuffer().putDouble(val);
-      bodyLength += SIZE_DOUBLE;
-   }
-
-   public void putShort(short val)
-   {
-      getMessagingBuffer().putShort(val);
-      bodyLength += SIZE_SHORT;
-   }
-
-   public void putChar(char val)
-   {
-      getMessagingBuffer().putChar(val);
-      bodyLength += SIZE_CHAR;
-   }
-
-   public void putBoolean(boolean b)
-   {
-      getMessagingBuffer().putBoolean(b);
-      bodyLength += SIZE_BOOLEAN;
-   }
-
-   public int getInt()
-   {
-      return getMessagingBuffer().getInt();
-   }
-
-   public long getLong()
-   {
-      return getMessagingBuffer().getLong();
-   }
-
-   public short getShort()
-   {
-      return getMessagingBuffer().getShort();
-   }
-
-   public boolean getBoolean()
-   {
-      return getMessagingBuffer().getBoolean();
-   }
-
-   public byte getByte()
-   {
-      return getMessagingBuffer().getByte();
-   }
-
-   public void getBytes(byte[] data)
-   {
-      getMessagingBuffer().getBytes(data);
-   }
-
-   public void getBytes(byte[] data, int read, int left)
-   {
-      getMessagingBuffer().getBytes(data, read, left);
-   }
-
-   public float getFloat()
-   {
-      return getMessagingBuffer().getFloat();
-   }
-
-   public double getDouble()
-   {
-      return getMessagingBuffer().getDouble();
-   }
-
-   public char getChar()
-   {
-      return getMessagingBuffer().getChar();
-   }
-
-   public short getUnsignedByte()
-   {
-      return getMessagingBuffer().getUnsignedByte();
-   }
-
-   public int getBodyLength()
-   {
-      return bodyLength;
-   }
-
-   public void setBodyLength(int bodyLength)
-   {
-      this.bodyLength = bodyLength;
-   }
-
-   public int remaining()
-   {
-      return getMessagingBuffer().remaining();
-   }
-
-   public int limit()
-   {
-      return getMessagingBuffer().limit() - HEADER_SIZE;
-   }
-
-   public void writeHeaders()
-   {
-      getMessagingBuffer().putInt(0, getLength() - SIZE_INT);
-      //we initially wrote true anyway
-      if(!isLastPacket())
-      {
-         getMessagingBuffer().putBoolean(SIZE_INT, isLastPacket());
-      }
-   }
-
-   public PacketFragment createNextPacketFragment(int packetFragmentSize)
-   {
-      lastPacket = false;
-      return new PacketFragmentImpl(packetId, correlationId + 1,
-            getMessagingBuffer().createNewBuffer(packetFragmentSize));
-   }
-
-   public void putBoolean(int pos, boolean val)
-   {
-      getMessagingBuffer().putBoolean(pos + HEADER_SIZE, val);
-   }
-
-   public void putInt(int pos, int val)
-   {
-      getMessagingBuffer().putInt(pos + HEADER_SIZE,  val);
-   }
-
-   public void rewind()
-   {
-      getMessagingBuffer().rewind();
-   }
-
-   public void flip()
-   {
-      getMessagingBuffer().flip();
-   }
-
-   public void position(int position)
-   {
-      getMessagingBuffer().position(position);
-   }
-}

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,12 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
 import org.jboss.messaging.core.client.Location;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
@@ -36,6 +30,13 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.spi.Connection;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
 /**
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -77,7 +78,7 @@
 
    private volatile boolean destroyed;
 
-   private PacketAssembler packetAssembler;
+   private AtomicInteger packetIdCreator = new AtomicInteger(0);
 
    // Constructors
    // ---------------------------------------------------------------------------------
@@ -85,8 +86,7 @@
    public RemotingConnectionImpl(final Connection transportConnection,
          final PacketDispatcher dispatcher, final Location location,
          final long blockingCallTimeout, final long pingPeriod,
-         final ScheduledExecutorService pingExecutor,
-         final PacketAssembler packetAssembler)
+         final ScheduledExecutorService pingExecutor)
    {
       this.transportConnection = transportConnection;
 
@@ -96,22 +96,23 @@
 
       this.blockingCallTimeout = blockingCallTimeout;
 
-      this.packetAssembler = packetAssembler;
-
       pinger = new Pinger();
 
       pongHandler = new PongHandler(dispatcher.generateID());
 
       dispatcher.register(pongHandler);
 
-      future = pingExecutor.scheduleWithFixedDelay(pinger, pingPeriod, pingPeriod,
-                                                   TimeUnit.MILLISECONDS);
+      if (pingPeriod > 0)
+      {
+         future = pingExecutor.scheduleWithFixedDelay(pinger, pingPeriod, pingPeriod,
+                                                      TimeUnit.MILLISECONDS);
+      }
 
    }
 
    public RemotingConnectionImpl(final Connection transportConnection,
          final PacketDispatcher dispatcher, final Location location,
-         final long blockingCallTimeout, PacketAssembler packetAssembler)
+         final long blockingCallTimeout)
    {
       this.transportConnection = transportConnection;
 
@@ -120,8 +121,6 @@
       this.location = location;
 
       this.blockingCallTimeout = blockingCallTimeout;
-
-      this.packetAssembler = packetAssembler;
    }
 
    // Public
@@ -303,9 +302,14 @@
          throw new IllegalStateException("Cannot write packet to connection, it is destroyed");
       }
       
-      MessagingBuffer buffer = transportConnection.createBuffer(packetAssembler.getInitialPacketFragmentSize());
+      MessagingBuffer buffer = transportConnection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE);
 
-      packetAssembler.disAssemble(buffer, transportConnection, packet);
+      packet.encode(buffer, packetIdCreator.getAndIncrement());
+
+      for (MessagingBuffer buff : packet.getBuffers())
+      {
+         transportConnection.write(buff);   
+      }
    }
   
 

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingHandlerImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingHandlerImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingHandlerImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -21,15 +21,18 @@
  */ 
 package org.jboss.messaging.core.remoting.impl;
 
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CLOSE;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATECONNECTION;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATECONNECTION_RESP;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.EXCEPTION;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.NULL;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.PING;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.PONG;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.MessagingBuffer;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.core.remoting.RemotingHandler;
+import org.jboss.messaging.core.remoting.impl.wireformat.*;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.*;
 import static org.jboss.messaging.util.DataConstants.SIZE_INT;
+import org.jboss.messaging.util.ExecutorFactory;
+import org.jboss.messaging.util.OrderedExecutorFactory;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -38,51 +41,6 @@
 import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.*;
-import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.ConsumerFlowCreditMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionRequest;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
-import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.impl.wireformat.ProducerFlowCreditMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.ProducerSendMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.ReceiveMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowserHasNextMessageResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCancelMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateBrowserMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateBrowserResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateProducerMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateProducerResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateQueueMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAForgetMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAGetInDoubtXidsResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAGetTimeoutResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAJoinMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAPrepareMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAResumeMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXARollbackMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
-import org.jboss.messaging.util.ExecutorFactory;
-import org.jboss.messaging.util.OrderedExecutorFactory;
-
 /**
  * 
  * A RemotingHandlerImpl
@@ -102,9 +60,9 @@
    
    private final ConcurrentMap<Long, Long> lastPings = new ConcurrentHashMap<Long, Long>();
 
-   private PacketAssembler packetAssembler;
+   private Map<Long, Map<Integer,Packet>> packetsToDeliver = new HashMap<Long, Map<Integer, Packet>>();
 
-   public RemotingHandlerImpl(final PacketDispatcher dispatcher, final ExecutorService executorService, final PacketAssembler packetAssembler)
+   public RemotingHandlerImpl(final PacketDispatcher dispatcher, final ExecutorService executorService)
    {
       if (dispatcher == null)
       {
@@ -121,7 +79,6 @@
       {
          executorFactory = null;
       }
-      this.packetAssembler = packetAssembler;
    }
    
    public Set<Long> scanForFailedConnections(final long expirePeriod)
@@ -145,52 +102,71 @@
    
    public void bufferReceived(final long connectionID, final MessagingBuffer buffer) throws Exception
    {
-      final Packet packet = packetAssembler.assemble(buffer, this, connectionID);
+      int packetLength = buffer.getInt();
+      int packetId = buffer.getInt();
+      boolean lastPacket = buffer.getBoolean();
+      final Packet packet = getPacket(connectionID, packetId, buffer);
+      packet.addBuffer(buffer, packetLength);
 
-      if(packet == null)
+      if (lastPacket)
       {
-         return;
-      }
-               
-      if (executorFactory != null)
-      {
-         long executorID = packet.getExecutorID();
-
-         Executor executor = executors.get(executorID);
-         if (executor == null)
+         packetsToDeliver.get(connectionID).remove(packetId);
+         packet.decode();
+         if (executorFactory != null)
          {
-            executor = executorFactory.getExecutor();
+            long executorID = packet.getExecutorID();
 
-            Executor oldExecutor = executors.putIfAbsent(executorID, executor);
-
-            if (oldExecutor != null)
+            Executor executor = executors.get(executorID);
+            if (executor == null)
             {
-               //Avoid race
-               executor = oldExecutor;
+               executor = executorFactory.getExecutor();
+
+               Executor oldExecutor = executors.putIfAbsent(executorID, executor);
+
+               if (oldExecutor != null)
+               {
+                  //Avoid race
+                  executor = oldExecutor;
+               }
             }
-         }
 
-         executor.execute(new Runnable()
-         {
-            public void run()
+            executor.execute(new Runnable()
             {
-               try
+               public void run()
                {
-                  dispatcher.dispatch(connectionID, packet);
+                  try
+                  {
+                     dispatcher.dispatch(connectionID, packet);
+                  }
+                  catch (Exception e)
+                  {
+                     log.error("unexpected error", e);
+                  }
                }
-               catch (Exception e)
-               {
-                  log.error("unexpected error", e);
-               }
-            }
-         });
+            });
+         }
+         else
+         {
+            dispatcher.dispatch(connectionID, packet);
+         }
       }
-      else
+   }
+
+   private Packet getPacket(long connectionID, int packetId, MessagingBuffer buffer)
+   {
+       if(packetsToDeliver.get(connectionID) == null)
       {
-         dispatcher.dispatch(connectionID, packet);
-      }      
+         packetsToDeliver.put(connectionID, new HashMap<Integer, Packet>());
+      }
+      Packet packet = packetsToDeliver.get(connectionID).get(packetId);
+      if (packet == null)
+      {
+         packet = createPacket(connectionID, buffer);
+         packetsToDeliver.get(connectionID).put(packetId, packet);
+      }
+      return packet;
    }
-   
+
    public int isReadyToHandle(final MessagingBuffer buffer)
    {
       if (buffer.remaining() <= SIZE_INT)
@@ -227,11 +203,21 @@
    {
       return executors.size();
    }
-   
+
    public Packet decode(final long connectionID, final MessagingBuffer in) throws Exception
-   {     
+   {
+      Packet packet = createPacket(connectionID, in);
+
+      packet.decode();
+
+      return packet;
+
+   }
+
+   private Packet createPacket(long connectionID, MessagingBuffer in)
+   {
       byte packetType = in.getByte();
-      
+
       Packet packet;
 
       switch (packetType)
@@ -512,13 +498,9 @@
             throw new IllegalArgumentException("Invalid type: " + packetType);
          }
       }
-
-      packet.decode(in);
-      
       return packet;
+   }
 
-   }   
-   
    // Private -----------------------------------------------------------------------------
    
    

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -74,9 +74,6 @@
    
    private TimerTask failedConnectionsTask;
 
-   private PacketAssembler packetAssembler;
-   private PacketFragmentCache packetFragmentCache;
-
    // Static --------------------------------------------------------
    
    // Constructors --------------------------------------------------
@@ -90,11 +87,7 @@
       dispatcher = new PacketDispatcherImpl(null);
 
       remotingExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("JBM-session-ordering-threads"));
-
-      packetFragmentCache = new InMemoryPacketFragmentCache();
-
-      packetAssembler = new PacketAssemblerImpl(config.getInitialPacketFragmentSize(), config.getPacketFragmentSize(), packetFragmentCache);
-      handler = new RemotingHandlerImpl(dispatcher, remotingExecutor, packetAssembler);
+      handler = new RemotingHandlerImpl(dispatcher, remotingExecutor);
       
       long pingPeriod = config.getConnectionParams().getPingInterval();
       
@@ -228,7 +221,7 @@
    public void connectionCreated(final Connection connection)
    {
       RemotingConnection rc =
-         new RemotingConnectionImpl(connection, dispatcher, null, config.getConnectionParams().getCallTimeout(), packetAssembler);
+         new RemotingConnectionImpl(connection, dispatcher, null, config.getConnectionParams().getCallTimeout());
       
       this.connections.put(connection.getID(), rc);
    }
@@ -237,8 +230,6 @@
    {
       handler.removeLastPing(connectionID);
 
-      packetFragmentCache.clear(connectionID);
-
       if (connections.remove(connectionID) == null)
       {
          throw new IllegalStateException("Cannot find connection with id " + connectionID);
@@ -248,8 +239,6 @@
    public void connectionException(long connectionID, MessagingException me)
    {
       RemotingConnection rc = connections.remove(connectionID);
-
-      packetFragmentCache.clear(connectionID);
       
       if (rc == null)
       {

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionMessage.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -79,18 +77,18 @@
       return this.autoCommitAcks;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putBoolean(xa);
-      buffer.putBoolean(autoCommitSends);
-      buffer.putBoolean(autoCommitAcks);
+      putBoolean(xa);
+      putBoolean(autoCommitSends);
+      putBoolean(autoCommitAcks);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xa = buffer.getBoolean();
-      autoCommitSends = buffer.getBoolean();
-      autoCommitAcks = buffer.getBoolean();
+      xa = getBoolean();
+      autoCommitSends = getBoolean();
+      autoCommitAcks = getBoolean();
    }
    
    public boolean equals(Object other)

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionResponseMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionResponseMessage.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConnectionCreateSessionResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,9 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -62,14 +59,14 @@
       return sessionTargetID;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(sessionTargetID);
+      putLong(sessionTargetID);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      sessionTargetID = buffer.getLong();
+      sessionTargetID = getLong();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ConsumerFlowCreditMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -61,14 +59,14 @@
       return credits;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(credits);
+      putInt(credits);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      credits = buffer.getInt();
+      credits = getInt();
    }
 
    @Override

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionRequest.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionRequest.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionRequest.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -23,7 +23,6 @@
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
 import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -80,18 +79,18 @@
       return password;
    }
 
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(version);
-      buffer.putNullableString(username);
-      buffer.putNullableString(password);
+      putInt(version);
+      putNullableString(username);
+      putNullableString(password);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      version = buffer.getInt();
-      username = buffer.getNullableString();
-      password = buffer.getNullableString();
+      version = getInt();
+      username = getNullableString();
+      password = getNullableString();
    }
    
    @Override

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.core.version.Version;
 import org.jboss.messaging.core.version.impl.VersionImpl;
 
@@ -71,26 +70,26 @@
       return serverVersion;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(connectionTargetID);
-      buffer.putNullableString(serverVersion.getVersionName());
-      buffer.putInt(serverVersion.getMajorVersion());
-      buffer.putInt(serverVersion.getMinorVersion());
-      buffer.putInt(serverVersion.getMicroVersion());
-      buffer.putInt(serverVersion.getIncrementingVersion());
-      buffer.putNullableString(serverVersion.getVersionSuffix());
+      putLong(connectionTargetID);
+      putNullableString(serverVersion.getVersionName());
+      putInt(serverVersion.getMajorVersion());
+      putInt(serverVersion.getMinorVersion());
+      putInt(serverVersion.getMicroVersion());
+      putInt(serverVersion.getIncrementingVersion());
+      putNullableString(serverVersion.getVersionSuffix());
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      connectionTargetID = buffer.getLong();
-      String versionName = buffer.getNullableString();
-      int majorVersion = buffer.getInt();
-      int minorVersion = buffer.getInt();
-      int microVersion = buffer.getInt();
-      int incrementingVersion = buffer.getInt();
-      String versionSuffix = buffer.getNullableString();
+      connectionTargetID = getLong();
+      String versionName = getNullableString();
+      int majorVersion = getInt();
+      int minorVersion = getInt();
+      int microVersion = getInt();
+      int incrementingVersion = getInt();
+      String versionSuffix = getNullableString();
       serverVersion =  new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, versionSuffix);
    }
 

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/MessagingExceptionMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -23,7 +23,6 @@
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
 import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -63,16 +62,16 @@
       return exception;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(exception.getCode());
-      buffer.putNullableString(exception.getMessage());
+      putInt(exception.getCode());
+      putNullableString(exception.getMessage());
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      int code = buffer.getInt();
-      String msg = buffer.getNullableString();
+      int code = getInt();
+      String msg = getNullableString();
       exception = new MessagingException(code, msg);
    }
    

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -26,8 +26,17 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.transaction.impl.XidImpl;
 import org.jboss.messaging.util.DataConstants;
+import static org.jboss.messaging.util.DataConstants.*;
+import org.jboss.messaging.util.SimpleString;
 
+import javax.transaction.xa.Xid;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -40,6 +49,8 @@
    
    private static final Logger log = Logger.getLogger(PacketImpl.class);
 
+   private static final Charset utf8 = Charset.forName("UTF-8");
+
    public static final long NO_ID_SET = -1L;
    
    public static final int INITIAL_BUFFER_SIZE = 1024;
@@ -125,6 +136,10 @@
    
    public static final byte RECEIVE_MSG = 110;
 
+   private List<MessagingBuffer> buffers = new ArrayList<MessagingBuffer>();
+   private List<Integer> buffersSizes = new ArrayList<Integer>();
+   private int currentPos = 0;
+
    // Static --------------------------------------------------------
 
    public PacketImpl(final byte type)
@@ -186,33 +201,39 @@
       setTargetID(other.getResponseTargetID());
    }
 
-   public void encode(MessagingBuffer buffer)
+   public void encode(MessagingBuffer buffer, int packetId)
    {      
       //The standard header fields
-      buffer.putByte(type); 
-      buffer.putInt(commandID);
-      buffer.putLong(responseTargetID);
-      buffer.putLong(targetID);
-      buffer.putLong(executorID);
+      buffers.add(buffer);
+      //length filled at end
+      getCurrentBuffer().putInt(-1);
+      //are we the last packet, filled at end.
+      getCurrentBuffer().putInt(packetId);
+      getCurrentBuffer().putBoolean(false);
+      putByte(type);
+      putInt(commandID);
+      putLong(responseTargetID);
+      putLong(targetID);
+      putLong(executorID);
 
-      encodeBody(buffer);
+      encodeBody();
    }
 
-   public void decode(final MessagingBuffer buffer)
+   public void decode()
    {
-      commandID = buffer.getInt();
-      responseTargetID = buffer.getLong();
-      targetID = buffer.getLong();
-      executorID = buffer.getLong();
+      commandID = getInt();
+      responseTargetID = getLong();
+      targetID = getLong();
+      executorID = getLong();
       
-      decodeBody(buffer);
+      decodeBody();
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {      
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {      
    }
 
@@ -238,17 +259,438 @@
              r.targetID == this.targetID;
    }
    
+
+
+   public void putXidType(Xid xid)
+   {
+      putInt(xid.getFormatId());
+      putInt(xid.getBranchQualifier().length);
+      putBytes(xid.getBranchQualifier());
+      putInt(xid.getGlobalTransactionId().length);
+      putBytes(xid.getGlobalTransactionId());
+   }
+
+   public void putFloat(float val)
+   {
+      checkWriteSpace(SIZE_FLOAT);
+      getCurrentBuffer().putFloat(val);
+   }
+
+   public void putInt(int i)
+   {
+      checkWriteSpace(SIZE_INT);
+      getCurrentBuffer().putInt(i);
+   }
+
+   public void putByte(byte b)
+   {
+      checkWriteSpace(SIZE_BYTE);
+      getCurrentBuffer().putByte(b);
+   }
+
+   public void putLong(long l)
+   {
+      checkWriteSpace(SIZE_LONG);
+      getCurrentBuffer().putLong(l);
+   }
+
+   public void putBoolean(boolean b)
+   {
+      checkWriteSpace(SIZE_BOOLEAN);
+      getCurrentBuffer().putBoolean(b);
+   }
+
+   public void putNullableString(String nullableString)
+   {
+      if (nullableString == null)
+		{
+			putByte(DataConstants.NULL);
+		}
+		else
+		{
+			putByte(DataConstants.NOT_NULL);
+
+			putString(nullableString);
+		}
+   }
+
+   public void putSimpleString(SimpleString string)
+   {
+      byte[] data = string.getData();
+
+   	putInt(data.length);
+   	putBytes(data);
+   }
+
+   public void putNullableSimpleString(SimpleString string)
+   {
+      if (string == null)
+   	{
+   		putByte(DataConstants.NULL);
+   	}
+   	else
+   	{
+   	   putByte(DataConstants.NOT_NULL);
+   		putSimpleString(string);
+   	}
+   }
+
+   public void putBytes(byte[] bytes, int i, int i1)
+   {
+      if(getCurrentBuffer().remaining() <= (i1 - i))
+      {
+         getCurrentBuffer().putBytes(bytes, i, i1);
+      }
+      else
+      {
+         int written = 0;
+         while(written < i1)
+         {
+            int left = getCurrentBuffer().remaining();
+            int towrite = left + written > i1?i1 - written:left;
+            getCurrentBuffer().putBytes(bytes, i, towrite);
+            written+=towrite;
+            i += left;
+            if(written < i1)
+            {
+               setNextFragment();
+            }
+         }
+      }
+   }
+
+   public void putBytes(byte[] bytes)
+   {
+      putBytes(bytes, 0, bytes.length);
+   }
+
+   public void putShort(short val)
+   {
+      checkWriteSpace(SIZE_SHORT);
+      getCurrentBuffer().putShort(val);
+   }
+
+   public void putDouble(double val)
+   {
+      checkWriteSpace(SIZE_DOUBLE);
+      getCurrentBuffer().putDouble(val);
+   }
+
+   public void putChar(char val)
+   {
+      checkWriteSpace(SIZE_CHAR);
+      getCurrentBuffer().putChar(val);
+   }
+
+   public void putUTF(String str)
+   {
+      //TODO This is quite inefficient - can be improved using a method similar to what MINA IOBuffer does
+		//(putPrefixedString)
+		ByteBuffer bb = utf8.encode(str);
+   	putInt(bb.limit() - bb.position());
+   	putBytes(bb.array());
+   }
+
+   public void putString(String string)
+   {
+      putInt(string.length());
+
+		for (int i = 0; i < string.length(); i++)
+		{
+			putChar(string.charAt(i));
+		}
+   }
+
+   public String getString()
+   {
+      int len = getInt();
+
+   	char[] chars = new char[len];
+
+      for (int i = 0; i < len; i++)
+      {
+      	chars[i] = getChar();
+      }
+
+      return new String(chars);
+   }
+
+   public Xid getXidType()
+   {
+      int formatID = getInt();
+      byte[] bq = new byte[getInt()];
+      getBytes(bq);
+      byte[] gtxid = new byte[getInt()];
+      getBytes(gtxid);
+      Xid xid = new XidImpl(bq, formatID, gtxid);
+      return xid;
+   }
+
+
+   public List<Xid> getXids(int len)
+   {
+      List<Xid> xids = new ArrayList<Xid>();
+
+      //  new ArrayList<Xid>(len);
+      for (int i = 0; i < len; i++)
+      {
+         int formatID = getInt();
+         byte[] bq = new byte[getInt()];
+         getBytes(bq);
+         byte[] gtxid = new byte[getInt()];
+         getBytes(gtxid);
+         Xid xid = new XidImpl(bq, formatID, gtxid);
+
+         xids.add(xid);
+      }
+      return xids;
+   }
+
+   public void getBytes(byte[] value, int i, int read)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public String getUTF() throws Exception
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   public int getInt()
+   {
+      checkReadSpace(SIZE_INT);
+      return getCurrentBuffer().getInt();
+   }
+
+   public long getLong()
+   {
+      checkReadSpace(SIZE_LONG);
+      return getCurrentBuffer().getLong();
+   }
+
+   public short getShort()
+   {
+      checkReadSpace(SIZE_SHORT);
+      return getCurrentBuffer().getShort();
+   }
+
+   public boolean getBoolean()
+   {
+      checkReadSpace(SIZE_BOOLEAN);
+      return getCurrentBuffer().getBoolean();
+   }
+
+   public String getNullableString()
+   {
+      byte check = getByte();
+
+		if (check == DataConstants.NULL)
+		{
+			return null;
+		}
+		else
+		{
+			return getString();
+		}
+   }
+
+   public SimpleString getSimpleString()
+   {
+      int len = getInt();
+
+   	byte[] data = new byte[len];
+   	getBytes(data);
+
+   	return new SimpleString(data);
+   }
+
+    public SimpleString getNullableSimpleString()
+   {
+      int b = getByte();
+   	if (b == DataConstants.NULL)
+   	{
+   	   return null;
+   	}
+   	else
+   	{
+         return getSimpleString();
+   	}
+   }
+
+   public byte getByte()
+   {
+      checkReadSpace(SIZE_BYTE);
+      return getCurrentBuffer().getByte();
+   }
+
+   public void getBytes(byte[] data)
+   {
+      int left = getCurrentBuffer().remaining();
+      if(data.length <= left)
+      {
+         getCurrentBuffer().getBytes(data);
+      }
+      else
+      {
+         int size = data.length;
+         int read = 0;
+         while (read < size)
+         {
+            left = getCurrentBuffer().remaining() <= (size - read)? getCurrentBuffer().remaining():size - read;
+
+            getCurrentBuffer().getBytes(data, read, left);
+            read += left;
+            if(read < size)
+            {
+               currentPos++;
+            }
+
+         }
+
+      }
+   }
+
+
+   public float getFloat()
+   {
+      checkReadSpace(SIZE_FLOAT);
+      return getCurrentBuffer().getFloat();
+   }
+
+   public double getDouble()
+   {
+      checkReadSpace(SIZE_DOUBLE);
+      return getCurrentBuffer().getDouble();
+   }
+
+   public char getChar()
+   {
+      checkReadSpace(SIZE_CHAR);
+      return getCurrentBuffer().getChar();
+   }
+
+   public short getUnsignedByte()
+   {
+      checkReadSpace(SIZE_SHORT);
+      return getCurrentBuffer().getUnsignedByte();
+   }
+
+   public int getUnsignedShort()
+   {
+     checkReadSpace(SIZE_INT);
+      return getCurrentBuffer().getUnsignedByte();
+   }
+
+   public void putBody(MessagingBuffer body)
+   {
+      putInt(body.limit());
+      if(getCurrentBuffer().remaining() > body.limit())
+      {
+         //copy contents
+         putBytes(body.array(), 0, body.limit());
+      }
+      else
+      {
+         buffers.add(body);
+      }
+   }
+
+   public List<MessagingBuffer> getBuffers()
+   {
+      for (int i = 0; i < buffers.size(); i++)
+      {
+         MessagingBuffer buffer = buffers.get(i);
+         buffer.putInt(0, buffer.position() - SIZE_INT);
+         if(i == buffers.size() - 1)
+         {
+            buffer.putBoolean(SIZE_INT * 2, true);
+         }
+         if(buffer.position() != 0)
+         {
+            buffer.flip();
+         }
+      }
+      return buffers;
+   }
+
+   public void addBuffer(MessagingBuffer buffer, int packetLength)
+   {
+      buffers.add(buffer);
+      buffersSizes.add(packetLength);
+   }
+
+   public MessagingBuffer getBodyType()
+   {
+      int bodyLength = getInt();
+      //if we are part way thru a buffer it must we need to copy into new buffer
+      if(getCurrentBuffer().position() - SIZE_INT != getCurrentBuffersSize())
+      {
+         MessagingBuffer body = getCurrentBuffer().createNewBuffer(bodyLength);
+         byte[] bytes = new byte[bodyLength];
+         getCurrentBuffer().getBytes(bytes);
+         body.putBytes(bytes);
+         return body;
+      }
+      //else we just return the remaining buffers
+      else
+      {
+         currentPos++;
+         return getCurrentBuffer();
+      }
+   }
+
    // Package protected ---------------------------------------------
 
-   protected String getParentString()
+     protected String getParentString()
+     {
+        return "PACKET[type=" + type
+        + ", responseTargetID=" + responseTargetID + ", targetID=" + targetID
+        + ", executorID=" + executorID;
+     }
+
+
+
+    // Private -------------------------------------------------------
+
+   private void checkReadSpace(int size)
    {
-      return "PACKET[type=" + type
-      + ", responseTargetID=" + responseTargetID + ", targetID=" + targetID
-      + ", executorID=" + executorID;
+      if(getCurrentBuffer().position() + size > getCurrentBuffersSize() + SIZE_INT )
+      {
+         currentPos++;
+      }
    }
 
-   // Protected -----------------------------------------------------
+   private void checkWriteSpace(int size)
+   {
+      if(getCurrentBuffer().remaining() < size)
+      {
+         setNextFragment();
+      }
+   }
 
+   private void setNextFragment()
+   {
+      buffers.add(buffers.get(0).createNewBuffer(INITIAL_BUFFER_SIZE));
+      currentPos++;
+   }
+
+
+   private MessagingBuffer getCurrentBuffer()
+   {
+      try
+      {
+         return buffers.get(currentPos);
+      }
+      catch (Exception e)
+      {
+         return null;
+      }
+   }
+
+   private int getCurrentBuffersSize()
+   {
+      return buffersSizes.get(currentPos);
+   }
    // Private -------------------------------------------------------
 
    // Inner classes -------------------------------------------------

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerFlowCreditMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * 
  * A ProducerFlowCreditMessage
@@ -62,14 +60,14 @@
       return credits;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(credits);
+      putInt(credits);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      credits = buffer.getInt();
+      credits = getInt();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ProducerSendMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,7 +24,6 @@
 
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
 
@@ -81,18 +80,18 @@
       return serverMessage;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      clientMessage.encode(buffer);
+      clientMessage.encode(this);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
       //TODO can be optimised
       
       serverMessage = new ServerMessageImpl();
       
-      serverMessage.decode(buffer);
+      serverMessage.decode(this);
       
       serverMessage.getBody().flip();
    }

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/ReceiveMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -25,7 +25,6 @@
 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.remoting.MessagingBuffer;
 import org.jboss.messaging.core.server.ServerMessage;
 
 /**
@@ -103,23 +102,23 @@
       return deliveryID;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(deliveryCount);
-      buffer.putLong(deliveryID);
-      serverMessage.encode(buffer);
+      putInt(deliveryCount);
+      putLong(deliveryID);
+      serverMessage.encode(this);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
       //TODO can be optimised
       
-      deliveryCount = buffer.getInt();
-      deliveryID = buffer.getLong();
+      deliveryCount = getInt();
+      deliveryID = getLong();
       
       clientMessage = new ClientMessageImpl(deliveryCount, deliveryID);
       
-      clientMessage.decode(buffer);
+      clientMessage.decode(this);
       
       clientMessage.getBody().flip();
    }

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAcknowledgeMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,9 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -70,16 +67,16 @@
       return allUpTo;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(deliveryID);
-      buffer.putBoolean(allUpTo);
+      putLong(deliveryID);
+      putBoolean(allUpTo);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      deliveryID = buffer.getLong();
-      allUpTo = buffer.getBoolean();
+      deliveryID = getLong();
+      allUpTo = getBoolean();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionAddDestinationMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -73,16 +72,16 @@
    	return temporary;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(address);
-      buffer.putBoolean(temporary);
+      putSimpleString(address);
+      putBoolean(temporary);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      address = buffer.getSimpleString();
-      temporary = buffer.getBoolean();
+      address = getSimpleString();
+      temporary = getBoolean();
    }
    
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -54,14 +53,14 @@
       return address;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(address);
+      putSimpleString(address);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      address = buffer.getSimpleString();
+      address = getSimpleString();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBindingQueryResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,12 +22,11 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
+import org.jboss.messaging.util.SimpleString;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-import org.jboss.messaging.util.SimpleString;
-
 /**
  * 
  * A SessionBindingQueryResponseMessage
@@ -65,24 +64,24 @@
       return this.queueNames;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putBoolean(exists);
-      buffer.putInt(queueNames.size());      
+      putBoolean(exists);
+      putInt(queueNames.size());
       for (SimpleString queueName: queueNames)
       {
-         buffer.putSimpleString(queueName);
+         putSimpleString(queueName);
       }      
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      exists = buffer.getBoolean();      
-      int numQueues = buffer.getInt();      
+      exists = getBoolean();
+      int numQueues = getInt();
       queueNames = new ArrayList<SimpleString>(numQueues);      
       for (int i = 0; i < numQueues; i++)
       {
-         queueNames.add(buffer.getSimpleString());
+         queueNames.add(getSimpleString());
       }          
    }
    

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionBrowserHasNextMessageResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -62,14 +60,14 @@
       return hasNext;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putBoolean(hasNext);
+      putBoolean(hasNext);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      hasNext = buffer.getBoolean();       
+      hasNext = getBoolean();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCancelMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,9 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -70,16 +67,16 @@
       return expired;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(deliveryID);
-      buffer.putBoolean(expired);
+      putLong(deliveryID);
+      putBoolean(expired);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      deliveryID = buffer.getLong();
-      expired = buffer.getBoolean();
+      deliveryID = getLong();
+      expired = getBoolean();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -71,16 +70,16 @@
       return filterString;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(queueName);
-      buffer.putNullableSimpleString(filterString);
+      putSimpleString(queueName);
+      putNullableSimpleString(filterString);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      queueName = buffer.getSimpleString();
-      filterString = buffer.getNullableSimpleString();
+      queueName = getSimpleString();
+      filterString = getNullableSimpleString();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateBrowserResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -62,14 +60,14 @@
       return browserTargetID;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(browserTargetID);
+      putLong(browserTargetID);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      browserTargetID = buffer.getLong();
+      browserTargetID = getLong();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -126,26 +125,26 @@
    	return maxRate;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(clientTargetID);
-      buffer.putSimpleString(queueName);
-      buffer.putNullableSimpleString(filterString);
-      buffer.putBoolean(noLocal);
-      buffer.putBoolean(autoDeleteQueue);
-      buffer.putInt(windowSize);
-      buffer.putInt(maxRate);
+      putLong(clientTargetID);
+      putSimpleString(queueName);
+      putNullableSimpleString(filterString);
+      putBoolean(noLocal);
+      putBoolean(autoDeleteQueue);
+      putInt(windowSize);
+      putInt(maxRate);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      clientTargetID = buffer.getLong();
-      queueName = buffer.getSimpleString();
-      filterString = buffer.getNullableSimpleString();
-      noLocal = buffer.getBoolean();
-      autoDeleteQueue = buffer.getBoolean();
-      windowSize = buffer.getInt();
-      maxRate = buffer.getInt();
+      clientTargetID = getLong();
+      queueName = getSimpleString();
+      filterString = getNullableSimpleString();
+      noLocal = getBoolean();
+      autoDeleteQueue = getBoolean();
+      windowSize = getInt();
+      maxRate = getInt();
    }
 
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateConsumerResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -70,16 +68,16 @@
    	return windowSize;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(consumerTargetID);
-      buffer.putInt(windowSize);
+      putLong(consumerTargetID);
+      putInt(windowSize);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      consumerTargetID = buffer.getLong();
-      windowSize = buffer.getInt();
+      consumerTargetID = getLong();
+      windowSize = getInt();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -100,20 +99,20 @@
    	return maxRate;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(clientTargetID);
-      buffer.putNullableSimpleString(address);
-      buffer.putInt(windowSize);
-      buffer.putInt(maxRate);
+      putLong(clientTargetID);
+      putNullableSimpleString(address);
+      putInt(windowSize);
+      putInt(maxRate);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      clientTargetID = buffer.getLong();      
-      address = buffer.getNullableSimpleString();      
-      windowSize = buffer.getInt();      
-      maxRate = buffer.getInt();
+      clientTargetID = getLong();
+      address = getNullableSimpleString();
+      windowSize = getInt();
+      maxRate = getInt();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateProducerResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,8 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -78,18 +76,18 @@
    	return maxRate;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putLong(producerTargetID);
-      buffer.putInt(initialCredits);
-      buffer.putInt(maxRate);
+      putLong(producerTargetID);
+      putInt(initialCredits);
+      putInt(maxRate);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      producerTargetID = buffer.getLong();      
-      initialCredits = buffer.getInt();
-      maxRate = buffer.getInt();
+      producerTargetID = getLong();
+      initialCredits = getInt();
+      maxRate = getInt();
    }
    
 

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionCreateQueueMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -103,22 +102,22 @@
       return temporary;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(address);
-      buffer.putSimpleString(queueName);
-      buffer.putNullableSimpleString(filterString);
-      buffer.putBoolean(durable);
-      buffer.putBoolean(temporary);
+      putSimpleString(address);
+      putSimpleString(queueName);
+      putNullableSimpleString(filterString);
+      putBoolean(durable);
+      putBoolean(temporary);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      address = buffer.getSimpleString();
-      queueName = buffer.getSimpleString();
-      filterString = buffer.getNullableSimpleString();
-      durable = buffer.getBoolean();
-      temporary = buffer.getBoolean();
+      address = getSimpleString();
+      queueName = getSimpleString();
+      filterString = getNullableSimpleString();
+      durable = getBoolean();
+      temporary = getBoolean();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionDeleteQueueMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -70,14 +69,14 @@
       return queueName;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(queueName);
+      putSimpleString(queueName);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      queueName = buffer.getSimpleString();
+      queueName = getSimpleString();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -54,14 +53,14 @@
       return queueName;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(queueName);
+      putSimpleString(queueName);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      queueName = buffer.getSimpleString();
+      queueName = getSimpleString();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionQueueQueryResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -124,28 +123,28 @@
       return address;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putBoolean(exists);
-      buffer.putBoolean(durable);
-      buffer.putBoolean(temporary);
-      buffer.putInt(maxSize);
-      buffer.putInt(consumerCount);
-      buffer.putInt(messageCount);
-      buffer.putNullableSimpleString(filterString);
-      buffer.putNullableSimpleString(address);
+      putBoolean(exists);
+      putBoolean(durable);
+      putBoolean(temporary);
+      putInt(maxSize);
+      putInt(consumerCount);
+      putInt(messageCount);
+      putNullableSimpleString(filterString);
+      putNullableSimpleString(address);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      exists = buffer.getBoolean();
-      durable = buffer.getBoolean();
-      temporary = buffer.getBoolean();
-      maxSize = buffer.getInt();
-      consumerCount = buffer.getInt();
-      messageCount = buffer.getInt();
-      filterString  = buffer.getNullableSimpleString();
-      address = buffer.getNullableSimpleString();
+      exists = getBoolean();
+      durable = getBoolean();
+      temporary = getBoolean();
+      maxSize = getInt();
+      consumerCount = getInt();
+      messageCount = getInt();
+      filterString  = getNullableSimpleString();
+      address = getNullableSimpleString();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionRemoveDestinationMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,7 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -73,16 +72,16 @@
    	return temporary;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putSimpleString(address);
-      buffer.putBoolean(temporary);
+      putSimpleString(address);
+      putBoolean(temporary);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      address = buffer.getSimpleString();
-      temporary = buffer.getBoolean();
+      address = getSimpleString();
+      temporary = getBoolean();
    }
       
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXACommitMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -71,18 +69,19 @@
       return onePhase;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
-      buffer.putBoolean(onePhase);
+      putXidType(xid);
+      putBoolean(onePhase);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
-      onePhase = buffer.getBoolean();
+      xid = getXidType();
+      onePhase = getBoolean();
    }
 
+
    @Override
    public String toString()
    {

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAEndMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -72,16 +70,16 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
-      buffer.putBoolean(failed);
+      putXidType(xid);
+      putBoolean(failed);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
-      failed = buffer.getBoolean();
+      xid = getXidType();
+      failed = getBoolean();
    }
 
    @Override

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAForgetMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +61,14 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
+      putXidType(xid);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
+      xid = getXidType();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetInDoubtXidsResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,14 +22,10 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import java.util.ArrayList;
+import javax.transaction.xa.Xid;
 import java.util.List;
 
-import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -66,28 +62,24 @@
       return xids;
    }
 
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(xids.size());
+      putInt(xids.size());
 
       for (Xid xid: xids)
       {
-         XidCodecSupport.encodeXid(xid, buffer);
+         putXidType(xid);
       }    
    }
-   
-   public void decodeBody(final MessagingBuffer buffer)
+
+   public void decodeBody()
    {
-      int len = buffer.getInt();
-      xids = new ArrayList<Xid>(len);      
-      for (int i = 0; i < len; i++)
-      {
-         Xid xid = XidCodecSupport.decodeXid(buffer);
-         
-         xids.add(xid);
-      }      
+      int len = getInt();
+      xids = getXids(len);    
    }
-   
+
+
+
    public boolean equals(Object other)
    {
       if (other instanceof SessionXAGetInDoubtXidsResponseMessage == false)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAGetTimeoutResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,10 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +59,14 @@
       return this.timeoutSeconds;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(timeoutSeconds);  
+      putInt(timeoutSeconds);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      timeoutSeconds = buffer.getInt(); 
+      timeoutSeconds = getInt();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAJoinMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +61,14 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
+      putXidType(xid);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
+      xid = getXidType();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAPrepareMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +61,14 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
+      putXidType(xid);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
+      xid = getXidType();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,9 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -79,18 +76,18 @@
       return message;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putBoolean(error);      
-      buffer.putInt(responseCode);      
-      buffer.putNullableString(message);
+      putBoolean(error);
+      putInt(responseCode);
+      putNullableString(message);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      error = buffer.getBoolean();      
-      responseCode = buffer.getInt();      
-      message = buffer.getNullableString();
+      error = getBoolean();
+      responseCode = getInt();
+      message = getNullableString();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAResumeMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +61,14 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
+      putXidType(xid);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
+      xid = getXid();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXARollbackMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +61,14 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
+      putXidType(xid);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
+      xid = getXid();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,10 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +59,14 @@
       return this.timeoutSeconds;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putInt(timeoutSeconds);
+      putInt(timeoutSeconds);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      timeoutSeconds = buffer.getInt();
+      timeoutSeconds = getInt();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXASetTimeoutResponseMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,9 +22,6 @@
 
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -61,14 +58,14 @@
       return ok;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      buffer.putBoolean(ok);
+      putBoolean(ok);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      ok = buffer.getBoolean();
+      ok = getBoolean();
    }
    
    public boolean equals(Object other)

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionXAStartMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -24,9 +24,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.remoting.MessagingBuffer;
 
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * 
@@ -63,14 +61,14 @@
       return xid;
    }
    
-   public void encodeBody(final MessagingBuffer buffer)
+   public void encodeBody()
    {
-      XidCodecSupport.encodeXid(xid, buffer);
+      putXidType(xid);
    }
    
-   public void decodeBody(final MessagingBuffer buffer)
+   public void decodeBody()
    {
-      xid = XidCodecSupport.decodeXid(buffer);
+      xid = getXidType();
    }
    
    public boolean equals(Object other)

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/jms/client/JBossMessage.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/jms/client/JBossMessage.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/jms/client/JBossMessage.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -880,7 +880,7 @@
    public void doBeforeSend() throws Exception
    {
       body.flip();
-      
+
       message.setBody(body);
    }
    

Modified: branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/util/TypedProperties.java
===================================================================
--- branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/util/TypedProperties.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/src/main/org/jboss/messaging/util/TypedProperties.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -22,36 +22,17 @@
 
 package org.jboss.messaging.util;
 
-import static org.jboss.messaging.util.DataConstants.BOOLEAN;
-import static org.jboss.messaging.util.DataConstants.BYTE;
-import static org.jboss.messaging.util.DataConstants.BYTES;
-import static org.jboss.messaging.util.DataConstants.CHAR;
-import static org.jboss.messaging.util.DataConstants.DOUBLE;
-import static org.jboss.messaging.util.DataConstants.FLOAT;
-import static org.jboss.messaging.util.DataConstants.INT;
-import static org.jboss.messaging.util.DataConstants.LONG;
-import static org.jboss.messaging.util.DataConstants.NOT_NULL;
-import static org.jboss.messaging.util.DataConstants.NULL;
-import static org.jboss.messaging.util.DataConstants.SHORT;
-import static org.jboss.messaging.util.DataConstants.SIZE_BOOLEAN;
-import static org.jboss.messaging.util.DataConstants.SIZE_BYTE;
-import static org.jboss.messaging.util.DataConstants.SIZE_CHAR;
-import static org.jboss.messaging.util.DataConstants.SIZE_DOUBLE;
-import static org.jboss.messaging.util.DataConstants.SIZE_FLOAT;
-import static org.jboss.messaging.util.DataConstants.SIZE_INT;
-import static org.jboss.messaging.util.DataConstants.SIZE_LONG;
-import static org.jboss.messaging.util.DataConstants.SIZE_SHORT;
-import static org.jboss.messaging.util.DataConstants.STRING;
+import org.jboss.messaging.core.journal.EncodingSupport;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.MessagingBuffer;
+import org.jboss.messaging.core.remoting.Packet;
+import static org.jboss.messaging.util.DataConstants.*;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-import org.jboss.messaging.core.journal.EncodingSupport;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.MessagingBuffer;
-
 /**
  * 
  * A TypedProperties
@@ -268,8 +249,111 @@
    		}
    	}
    }
-	
-	public void encode(final MessagingBuffer buffer)
+
+   public void decode(final Packet buffer)
+   {
+   	byte b = buffer.getByte();
+
+   	if (b == NULL)
+   	{
+   		properties = null;
+   	}
+   	else
+   	{
+   	   int numHeaders = buffer.getInt();
+
+      	properties = new HashMap<SimpleString, PropertyValue>(numHeaders);
+      	size = 0;
+
+   		for (int i = 0; i < numHeaders; i++)
+   		{
+   			int len = buffer.getInt();
+   			byte[] data = new byte[len];
+   			buffer.getBytes(data);
+   			SimpleString key = new SimpleString(data);
+
+   			byte type = buffer.getByte();
+
+   			PropertyValue val;
+
+   			switch (type)
+   			{
+   			   case NULL:
+   			   {
+   			      val = new NullValue();
+   			      doPutValue(key, val);
+   			      break;
+   			   }
+   			   case CHAR:
+   			   {
+   			      val = new CharValue(buffer);
+   			      doPutValue(key, val);
+   			      break;
+   			   }
+   				case BOOLEAN:
+   				{
+   					val = new BooleanValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case BYTE:
+   				{
+   					val = new ByteValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case BYTES:
+   				{
+   				   val = new BytesValue(buffer);
+   				   doPutValue(key, val);
+   				   break;
+   				}
+   				case SHORT:
+   				{
+   					val = new ShortValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case INT:
+   				{
+   					val = new IntValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case LONG:
+   				{
+   					val = new LongValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case FLOAT:
+   				{
+   					val = new FloatValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case DOUBLE:
+   				{
+   					val = new DoubleValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				case STRING:
+   				{
+   					val = new StringValue(buffer);
+   					doPutValue(key, val);
+   					break;
+   				}
+   				default:
+   				{
+   					throw new IllegalArgumentException("Invalid type: " + type);
+   				}
+   			}
+   		}
+   	}
+   }
+
+   public void encode(final MessagingBuffer buffer)
 	{
 		if (properties == null)
 		{
@@ -292,9 +376,33 @@
    		}
 		}
 	}
-	
-	public int getEncodeSize()
+
+   public void encode(final Packet buffer)
 	{
+		if (properties == null)
+		{
+			buffer.putByte(NULL);
+		}
+		else
+		{
+			buffer.putByte(NOT_NULL);
+
+   		buffer.putInt(properties.size());
+
+      	for (Map.Entry<SimpleString, PropertyValue> entry: properties.entrySet())
+   		{
+      		SimpleString s = entry.getKey();
+      		byte[] data = s.getData();
+      		buffer.putInt(data.length);
+      		buffer.putBytes(data);
+
+      		entry.getValue().write(buffer);
+   		}
+		}
+	}
+
+   public int getEncodeSize()
+	{
 	   if (properties == null)
 	   {
 	      return SIZE_BYTE;
@@ -384,8 +492,10 @@
 		Object getValue();	
 		
 		void write(MessagingBuffer buffer);
-		
-		int encodeSize();
+
+      void write(Packet buffer);
+
+      int encodeSize();
 	}
    
    private static final class NullValue implements PropertyValue
@@ -403,6 +513,11 @@
       {
          buffer.putByte(NULL);
       }
+
+      public void write(final Packet buffer)
+      {
+         buffer.putByte(NULL);
+      }
       
       public int encodeSize()
       {
@@ -424,9 +539,14 @@
 		{
 			this.val = buffer.getBoolean();
 		}
-		
-		public Object getValue()
+
+      public BooleanValue(final Packet buffer)
 		{
+			this.val = buffer.getBoolean();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -436,6 +556,12 @@
 			buffer.putBoolean(val);
 		}
 
+      public void write(Packet buffer)
+      {
+         buffer.putByte(BOOLEAN);
+			buffer.putBoolean(val);
+      }
+
       public int encodeSize()
       {
          return SIZE_BYTE + SIZE_BOOLEAN;
@@ -456,9 +582,14 @@
 		{
 			this.val = buffer.getByte();
 		}
-		
-		public Object getValue()
+
+      public ByteValue(final Packet buffer)
 		{
+			this.val = buffer.getByte();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -467,9 +598,15 @@
 			buffer.putByte(BYTE);
 			buffer.putByte(val);
 		}
-		
-		public int encodeSize()
+
+      public void write(final Packet buffer)
 		{
+			buffer.putByte(BYTE);
+			buffer.putByte(val);
+		}
+
+      public int encodeSize()
+		{
 		   return SIZE_BYTE + SIZE_BYTE;
 		}
 	}
@@ -489,9 +626,16 @@
 			this.val = new byte[len];
 			buffer.getBytes(val);
 		}
-		
-		public Object getValue()
+
+      public BytesValue(final Packet buffer)
 		{
+			int len = buffer.getInt();
+			this.val = new byte[len];
+			buffer.getBytes(val);
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -501,6 +645,13 @@
 			buffer.putInt(val.length);
 			buffer.putBytes(val);
 		}
+
+      public void write(final Packet buffer)
+		{
+			buffer.putByte(BYTES);
+			buffer.putInt(val.length);
+			buffer.putBytes(val);
+		}
 		
       public int encodeSize()
       {
@@ -522,9 +673,14 @@
 		{
 			this.val = buffer.getShort();
 		}
-		
-		public Object getValue()
+
+      public ShortValue(final Packet buffer)
 		{
+			this.val = buffer.getShort();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -533,9 +689,15 @@
 			buffer.putByte(SHORT);
 			buffer.putShort(val);
 		}
-		
-		public int encodeSize()
+
+      public void write(final Packet buffer)
 		{
+			buffer.putByte(SHORT);
+			buffer.putShort(val);
+		}
+
+      public int encodeSize()
+		{
 		   return SIZE_BYTE + SIZE_SHORT;
 		}
 	}
@@ -553,9 +715,14 @@
 		{
 			this.val = buffer.getInt();
 		}
-			
-		public Object getValue()
+
+      public IntValue(final Packet buffer)
 		{
+			this.val = buffer.getInt();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -565,7 +732,13 @@
 			buffer.putInt(val);
 		}
 
-		public int encodeSize()
+      public void write(final Packet buffer)
+		{
+			buffer.putByte(INT);
+			buffer.putInt(val);
+		}
+
+      public int encodeSize()
       {
          return SIZE_BYTE + SIZE_INT;
       }
@@ -585,8 +758,13 @@
 			this.val = buffer.getLong();
 		}
 
-		public Object getValue()
+      public LongValue(final Packet buffer)
 		{
+			this.val = buffer.getLong();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -596,7 +774,13 @@
 			buffer.putLong(val);
 		}
 
-		public int encodeSize()
+      public void write(final Packet buffer)
+		{
+			buffer.putByte(LONG);
+			buffer.putLong(val);
+		}
+
+      public int encodeSize()
       {
          return SIZE_BYTE + SIZE_LONG;
       }
@@ -615,9 +799,13 @@
 		{
 			this.val = buffer.getFloat();
 		}
-		
-		public Object getValue()
+      public FloatValue(final Packet buffer)
 		{
+			this.val = buffer.getFloat();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -626,6 +814,12 @@
 			buffer.putByte(FLOAT);
 			buffer.putFloat(val);
 		}
+
+      public void write(final Packet buffer)
+		{
+			buffer.putByte(FLOAT);
+			buffer.putFloat(val);
+		}
 		
       public int encodeSize()
       {
@@ -647,9 +841,14 @@
 		{
 			this.val = buffer.getDouble();
 		}
-		
-		public Object getValue()
+
+      public DoubleValue(final Packet buffer)
 		{
+			this.val = buffer.getDouble();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -659,7 +858,13 @@
 			buffer.putDouble(val);
 		}
 
-		public int encodeSize()
+      public void write(final Packet buffer)
+		{
+			buffer.putByte(DOUBLE);
+			buffer.putDouble(val);
+		}
+
+      public int encodeSize()
       {
          return SIZE_BYTE + SIZE_DOUBLE;
       }
@@ -678,9 +883,14 @@
 		{
 			this.val = buffer.getChar();
 		}
-		
-		public Object getValue()
+
+      public CharValue(final Packet buffer)
 		{
+			this.val = buffer.getChar();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -690,7 +900,13 @@
 			buffer.putChar(val);
 		}
 
-		public int encodeSize()
+      public void write(final Packet buffer)
+		{
+			buffer.putByte(CHAR);
+			buffer.putChar(val);
+		}
+
+      public int encodeSize()
       {
          return SIZE_BYTE + SIZE_CHAR;
       }
@@ -709,9 +925,14 @@
 		{
 			this.val = buffer.getSimpleString();
 		}
-		
-		public Object getValue()
+
+      public StringValue(final Packet buffer)
 		{
+			this.val = buffer.getSimpleString();
+		}
+
+      public Object getValue()
+		{
 			return val;
 		}
 		
@@ -720,9 +941,15 @@
 			buffer.putByte(STRING);
 			buffer.putSimpleString(val);
 		}
-		
-		public int encodeSize()
+
+      public void write(final Packet buffer)
 		{
+			buffer.putByte(STRING);
+			buffer.putSimpleString(val);
+		}
+
+      public int encodeSize()
+		{
 		   return SIZE_BYTE + SimpleString.sizeofString(val);
 		}
 	}

Modified: branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingConnectionImplTest.java
===================================================================
--- branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingConnectionImplTest.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingConnectionImplTest.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -30,7 +30,6 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.*;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.impl.PacketAssemblerImpl;
 import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.spi.Connection;
@@ -116,7 +115,7 @@
       
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, pingPeriod, ex, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, pingPeriod, ex);
             
       class Listener implements FailureListener
       {
@@ -167,7 +166,7 @@
       
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, pingPeriod, ex, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, pingPeriod, ex);
             
       class Listener implements FailureListener
       {
@@ -258,7 +257,7 @@
       
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, pingPeriod, ex, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, pingPeriod, ex);
             
       class Listener implements FailureListener
       {
@@ -305,7 +304,7 @@
       
       final long callTimeout = 100;
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, callTimeout, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, callTimeout);
             
       class Listener implements FailureListener
       {
@@ -413,7 +412,7 @@
 
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, callTimeout, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, callTimeout);
             
       class Listener implements FailureListener
       {

Modified: branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingHandlerImplTest.java
===================================================================
--- branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingHandlerImplTest.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/timing/core/remoting/impl/RemotingHandlerImplTest.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -26,7 +26,6 @@
 import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.impl.PacketAssemblerImpl;
 import org.jboss.messaging.core.remoting.impl.RemotingHandlerImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.tests.util.UnitTestCase;
@@ -54,7 +53,7 @@
       super.setUp();
       dispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
       executorService = EasyMock.createStrictMock(ExecutorService.class);
-      handler = new RemotingHandlerImpl(dispatcher, executorService, new PacketAssemblerImpl(1024, 1024, null));
+      handler = new RemotingHandlerImpl(dispatcher, executorService);
       buff = new ByteBufferWrapper(ByteBuffer.allocate(1024));
    }
 
@@ -71,25 +70,25 @@
       
       MessagingBuffer buff1 = new ByteBufferWrapper(ByteBuffer.allocate(1024));
       Packet ping1 = new PacketImpl(PacketImpl.PING);
-      ping1.encode(buff1); 
+      ping1.encode(buff1, 0);
       buff1.getInt();
       final long connectionID1 = 120912;
       
       MessagingBuffer buff2 = new ByteBufferWrapper(ByteBuffer.allocate(1024));
       Packet ping2 = new PacketImpl(PacketImpl.PING);
-      ping2.encode(buff2);      
+      ping2.encode(buff2, 1);
       buff2.getInt();
       final long connectionID2 = 12023;
       
       MessagingBuffer buff3 = new ByteBufferWrapper(ByteBuffer.allocate(1024));
       Packet ping3 = new PacketImpl(PacketImpl.PING);
-      ping3.encode(buff3);      
+      ping3.encode(buff3, 2);
       buff3.getInt();
       final long connectionID3 = 1123128;
       
       MessagingBuffer buff4 = new ByteBufferWrapper(ByteBuffer.allocate(1024));
       Packet ping4 = new PacketImpl(PacketImpl.PING);
-      ping4.encode(buff4);
+      ping4.encode(buff4, 3);
       buff4.getInt();
       final long connectionID4 = 127987;
       

Modified: branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionImplTest.java
===================================================================
--- branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionImplTest.java	2008-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingConnectionImplTest.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -30,7 +30,6 @@
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.*;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.impl.PacketAssemblerImpl;
 import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
 import org.jboss.messaging.core.remoting.spi.Connection;
@@ -57,7 +56,7 @@
       final long id = 12123;
       EasyMock.expect(connection.getID()).andReturn(id);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       EasyMock.replay(connection, dispatcher);
       
@@ -82,13 +81,13 @@
       
       EasyMock.expect(connection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE)).andReturn(buff);
       
-      packet.encode(buff);
+      packet.encode(buff, 0);
       
       connection.write(buff);
             
       EasyMock.replay(connection, dispatcher, packet, buff);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       rc.sendOneWay(targetID, executorID, packet);
       
@@ -106,13 +105,13 @@
       
       EasyMock.expect(connection.createBuffer(PacketImpl.INITIAL_BUFFER_SIZE)).andReturn(buff);
       
-      packet.encode(buff);
+      packet.encode(buff, 0);
       
       connection.write(buff);
             
       EasyMock.replay(connection, dispatcher, packet, buff);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       rc.sendOneWay(packet);
       
@@ -129,7 +128,7 @@
       
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       class Listener implements FailureListener
       {
@@ -194,7 +193,7 @@
       
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       class Listener implements FailureListener
       {
@@ -237,7 +236,7 @@
       
       EasyMock.replay(connection, dispatcher, buff);      
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       MessagingBuffer buff2 = rc.createBuffer(size);
       
@@ -250,7 +249,7 @@
       PacketDispatcher dispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
       Location location = new LocationImpl(TransportType.TCP, "blah", 1234);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       assertTrue(location == rc.getLocation());       
    }
@@ -261,7 +260,7 @@
       PacketDispatcher dispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
       Location location = new LocationImpl(TransportType.TCP, "blah", 1234);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       assertTrue(dispatcher == rc.getPacketDispatcher());       
    }
@@ -276,7 +275,7 @@
       
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000);
       
       rc.destroy();
       
@@ -318,7 +317,7 @@
       
       EasyMock.replay(connection, dispatcher, ex);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, pingPeriod, pingPeriod, ex, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, pingPeriod, pingPeriod, ex);
       
       rc.destroy();
       
@@ -391,7 +390,7 @@
 
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L);
             
       class Listener implements FailureListener
       {
@@ -485,7 +484,7 @@
 
       EasyMock.replay(connection, dispatcher);
       
-      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L, new PacketAssemblerImpl(1024, 1024, null));
+      RemotingConnection rc = new RemotingConnectionImpl(connection, dispatcher, location, 1000L);
             
       class Listener implements FailureListener
       {

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-07-31 19:19:13 UTC (rev 4761)
+++ branches/Branch_Message_Chunking_new/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/RemotingHandlerImplTest.java	2008-08-01 08:41:23 UTC (rev 4762)
@@ -28,7 +28,6 @@
 import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.impl.PacketAssemblerImpl;
 import org.jboss.messaging.core.remoting.impl.RemotingHandlerImpl;
 import org.jboss.messaging.core.remoting.impl.wireformat.*;
 import org.jboss.messaging.core.server.ServerMessage;
@@ -64,7 +63,7 @@
       super.setUp();
       dispatcher = EasyMock.createStrictMock(PacketDispatcher.class);
       executorService = EasyMock.createStrictMock(ExecutorService.class);
-      handler = new RemotingHandlerImpl(dispatcher, executorService, new PacketAssemblerImpl(1024, 1024, null));
+      handler = new RemotingHandlerImpl(dispatcher, executorService);
       buff = new ByteBufferWrapper(ByteBuffer.allocate(1024));
    }
 
@@ -114,7 +113,7 @@
    
    public void testBufferReceivedNoExecutor() throws Exception
    {
-      handler = new RemotingHandlerImpl(dispatcher, null, new PacketAssemblerImpl(1024, 1024, null));
+      handler = new RemotingHandlerImpl(dispatcher, null);
       
       Packet packet = new PacketImpl(PacketImpl.CLOSE);
       
@@ -124,7 +123,7 @@
       dispatcher.dispatch(connectionID, packet);
       EasyMock.expectLastCall().times(numTimes);
       
-      packet.encode(buff);
+      packet.encode(buff, 0);
       buff.getInt();
       
       EasyMock.replay(dispatcher);
@@ -150,7 +149,7 @@
       this.executorService.execute(EasyMock.isA(Runnable.class));
       EasyMock.expectLastCall().times(numTimes);
       
-      packet.encode(buff);
+      packet.encode(buff, 0);
       buff.getInt();
       
       EasyMock.replay(dispatcher);
@@ -181,7 +180,7 @@
          Packet packet = new PacketImpl(PacketImpl.CLOSE);
          packet.setExecutorID(i);
          MessagingBuffer buff = new ByteBufferWrapper(ByteBuffer.allocate(1024));
-         packet.encode(buff);
+         packet.encode(buff, 0);
          buff.getInt();
                   
          handler.bufferReceived(connectionID, buff);
@@ -222,7 +221,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.NULL);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -232,7 +231,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.CLOSE);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -242,7 +241,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.CONN_START);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -252,7 +251,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.CONN_STOP);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -262,7 +261,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_RECOVER);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -272,7 +271,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_COMMIT);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -282,7 +281,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_ROLLBACK);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -292,7 +291,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_BROWSER_RESET);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -302,7 +301,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_BROWSER_HASNEXTMESSAGE);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -312,7 +311,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_BROWSER_NEXTMESSAGE);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -322,7 +321,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_XA_INDOUBT_XIDS);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -332,7 +331,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_XA_GET_TIMEOUT);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -342,7 +341,7 @@
    {
       PacketImpl message = new PacketImpl(PacketImpl.SESS_XA_SUSPEND);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       PacketImpl copy = (PacketImpl) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -355,7 +354,7 @@
       message1.setDestination(new SimpleString("test"));
       PacketImpl message = new ProducerSendMessage(message1);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -375,7 +374,7 @@
       message1.setDestination(new SimpleString("test"));
       PacketImpl message = new ProducerSendMessage(message1);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -394,7 +393,7 @@
       message1.setDestination(new SimpleString("test"));
       PacketImpl message = new ProducerSendMessage(message1);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -414,7 +413,7 @@
       message1.setDestination(new SimpleString("test"));
       PacketImpl message = new ProducerSendMessage(message1);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -456,7 +455,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -509,7 +508,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -561,7 +560,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -614,7 +613,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerSendMessage copy = (ProducerSendMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -644,7 +643,7 @@
       message1.setBody(new ByteBufferWrapper(ByteBuffer.allocate(0)));
       PacketImpl message = new ReceiveMessage(message1, RandomUtil.randomInt(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -664,7 +663,7 @@
       message1.setBody(new ByteBufferWrapper(ByteBuffer.allocate(0)));
       PacketImpl message = new ReceiveMessage(message1, RandomUtil.randomInt(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -684,7 +683,7 @@
       message1.setBody(new ByteBufferWrapper(ByteBuffer.allocate(0)));
       PacketImpl message = new ReceiveMessage(message1, RandomUtil.randomInt(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -705,7 +704,7 @@
       message1.setBody(new ByteBufferWrapper(ByteBuffer.allocate(0)));
       PacketImpl message = new ReceiveMessage(message1, RandomUtil.randomInt(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -748,7 +747,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -800,7 +799,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -852,7 +851,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -905,7 +904,7 @@
       message1.putShortProperty(shortProp, RandomUtil.randomShort());
       SimpleString stringProp = new SimpleString("string.prop");
       message1.putStringProperty(stringProp, RandomUtil.randomSimpleString());
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ReceiveMessage copy = (ReceiveMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -932,7 +931,7 @@
    {
       ConnectionCreateSessionMessage message = new ConnectionCreateSessionMessage(true, true, true);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ConnectionCreateSessionMessage copy = (ConnectionCreateSessionMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -945,7 +944,7 @@
    {
       CreateConnectionRequest message = new CreateConnectionRequest(RandomUtil.randomInt(), RandomUtil.randomString(), RandomUtil.randomString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       CreateConnectionRequest copy = (CreateConnectionRequest) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -958,7 +957,7 @@
    {
       ConsumerFlowCreditMessage message = new ConsumerFlowCreditMessage(RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ConsumerFlowCreditMessage copy = (ConsumerFlowCreditMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -969,7 +968,7 @@
    {
       ConnectionCreateSessionResponseMessage message = new ConnectionCreateSessionResponseMessage(RandomUtil.randomLong());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ConnectionCreateSessionResponseMessage copy = (ConnectionCreateSessionResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -984,7 +983,7 @@
               RandomUtil.randomInt(),
               RandomUtil.randomInt(), RandomUtil.randomInt(), RandomUtil.randomString()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       CreateConnectionResponse copy = (CreateConnectionResponse) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -996,7 +995,7 @@
    {
       MessagingExceptionMessage message = new MessagingExceptionMessage(new MessagingException(RandomUtil.randomInt()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       MessagingExceptionMessage copy = (MessagingExceptionMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1007,7 +1006,7 @@
    {
       ProducerFlowCreditMessage message = new ProducerFlowCreditMessage(RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       ProducerFlowCreditMessage copy = (ProducerFlowCreditMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1018,7 +1017,7 @@
    {
       SessionAcknowledgeMessage message = new SessionAcknowledgeMessage(RandomUtil.randomLong(), RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionAcknowledgeMessage copy = (SessionAcknowledgeMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1030,7 +1029,7 @@
    {
       SessionAddDestinationMessage message = new SessionAddDestinationMessage(RandomUtil.randomSimpleString(), RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionAddDestinationMessage copy = (SessionAddDestinationMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1042,7 +1041,7 @@
    {
       SessionBindingQueryMessage message = new SessionBindingQueryMessage(RandomUtil.randomSimpleString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionBindingQueryMessage copy = (SessionBindingQueryMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1056,7 +1055,7 @@
       list.add(RandomUtil.randomSimpleString());
       SessionBindingQueryResponseMessage message = new SessionBindingQueryResponseMessage(RandomUtil.randomBoolean(), list);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionBindingQueryResponseMessage copy = (SessionBindingQueryResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1070,7 +1069,7 @@
    {
       SessionBrowserHasNextMessageResponseMessage message = new SessionBrowserHasNextMessageResponseMessage(RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionBrowserHasNextMessageResponseMessage copy = (SessionBrowserHasNextMessageResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1082,7 +1081,7 @@
    {
       SessionCancelMessage message = new SessionCancelMessage(RandomUtil.randomLong(), RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCancelMessage copy = (SessionCancelMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1095,7 +1094,7 @@
    {
       SessionCreateBrowserMessage message = new SessionCreateBrowserMessage(RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateBrowserMessage copy = (SessionCreateBrowserMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1108,7 +1107,7 @@
    {
       SessionCreateBrowserResponseMessage message = new SessionCreateBrowserResponseMessage(RandomUtil.randomLong());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateBrowserResponseMessage copy = (SessionCreateBrowserResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1122,7 +1121,7 @@
               RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean(),
               RandomUtil.randomInt(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateConsumerMessage copy = (SessionCreateConsumerMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1140,7 +1139,7 @@
    {
       SessionCreateConsumerResponseMessage message = new SessionCreateConsumerResponseMessage(RandomUtil.randomLong(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateConsumerResponseMessage copy = (SessionCreateConsumerResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1154,7 +1153,7 @@
       SessionCreateProducerMessage message = new SessionCreateProducerMessage(RandomUtil.randomLong(),
               RandomUtil.randomSimpleString(), RandomUtil.randomInt(), RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateProducerMessage copy = (SessionCreateProducerMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1170,7 +1169,7 @@
       SessionCreateProducerResponseMessage message = new SessionCreateProducerResponseMessage(RandomUtil.randomLong(), RandomUtil.randomInt(),
               RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateProducerResponseMessage copy = (SessionCreateProducerResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1185,7 +1184,7 @@
       SessionCreateQueueMessage message = new SessionCreateQueueMessage(RandomUtil.randomSimpleString(),
               RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString(), RandomUtil.randomBoolean(), RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionCreateQueueMessage copy = (SessionCreateQueueMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1200,7 +1199,7 @@
    {
       SessionDeleteQueueMessage message = new SessionDeleteQueueMessage(RandomUtil.randomSimpleString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionDeleteQueueMessage copy = (SessionDeleteQueueMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1211,7 +1210,7 @@
    {
       SessionQueueQueryMessage message = new SessionQueueQueryMessage(RandomUtil.randomSimpleString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionQueueQueryMessage copy = (SessionQueueQueryMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1224,7 +1223,7 @@
               RandomUtil.randomBoolean(), RandomUtil.randomInt(), RandomUtil.randomInt(), RandomUtil.randomInt(),
               RandomUtil.randomSimpleString(), RandomUtil.randomSimpleString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionQueueQueryResponseMessage copy = (SessionQueueQueryResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1242,7 +1241,7 @@
    {
       SessionRemoveDestinationMessage message = new SessionRemoveDestinationMessage(RandomUtil.randomSimpleString(), RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionRemoveDestinationMessage copy = (SessionRemoveDestinationMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1255,7 +1254,7 @@
       SessionXACommitMessage message = new SessionXACommitMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()),
               RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXACommitMessage copy = (SessionXACommitMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1270,7 +1269,7 @@
       SessionXAEndMessage message = new SessionXAEndMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()),
               RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAEndMessage copy = (SessionXAEndMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1284,7 +1283,7 @@
    {
       SessionXAForgetMessage message = new SessionXAForgetMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAForgetMessage copy = (SessionXAForgetMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1300,7 +1299,7 @@
       SessionXAGetInDoubtXidsResponseMessage message = new SessionXAGetInDoubtXidsResponseMessage(list);
       list.add(xids);
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAGetInDoubtXidsResponseMessage copy = (SessionXAGetInDoubtXidsResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1314,7 +1313,7 @@
    {
       SessionXAGetTimeoutResponseMessage message = new SessionXAGetTimeoutResponseMessage(RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAGetTimeoutResponseMessage copy = (SessionXAGetTimeoutResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1325,7 +1324,7 @@
    {
       SessionXAJoinMessage message = new SessionXAJoinMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAJoinMessage copy = (SessionXAJoinMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1338,7 +1337,7 @@
    {
       SessionXAPrepareMessage message = new SessionXAPrepareMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAPrepareMessage copy = (SessionXAPrepareMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1351,7 +1350,7 @@
    {
       SessionXAResponseMessage message = new SessionXAResponseMessage(RandomUtil.randomBoolean(), RandomUtil.randomInt(), RandomUtil.randomString());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAResponseMessage copy = (SessionXAResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1364,7 +1363,7 @@
    {
       SessionXAResumeMessage message = new SessionXAResumeMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAResumeMessage copy = (SessionXAResumeMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1377,7 +1376,7 @@
    {
       SessionXARollbackMessage message = new SessionXARollbackMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXARollbackMessage copy = (SessionXARollbackMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1390,7 +1389,7 @@
    {
       SessionXASetTimeoutMessage message = new SessionXASetTimeoutMessage(RandomUtil.randomInt());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXASetTimeoutMessage copy = (SessionXASetTimeoutMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1401,7 +1400,7 @@
    {
       SessionXASetTimeoutResponseMessage message = new SessionXASetTimeoutResponseMessage(RandomUtil.randomBoolean());
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXASetTimeoutResponseMessage copy = (SessionXASetTimeoutResponseMessage) handler.decode(123, buff);
       checkHeaders(message, copy);
@@ -1412,7 +1411,7 @@
    {
       SessionXAStartMessage message = new SessionXAStartMessage(new XidImpl(RandomUtil.randomBytes(), RandomUtil.randomInt(), RandomUtil.randomBytes()));
       setHeaders(message);
-      message.encode(buff);
+      message.encode(buff, 0);
       buff.getInt();
       SessionXAStartMessage copy = (SessionXAStartMessage) handler.decode(123, buff);
       checkHeaders(message, copy);




More information about the jboss-cvs-commits mailing list