3 Replies Latest reply on Jul 10, 2008 9:21 AM by Andy Taylor

    Handling Large Messages

    Andy Taylor Master
        • 2. Re: Handling Large Messages
          Tim Fox Master

          I think we should extend the concept of splitting packets into fragments to other packets too - not just message sends and receives, since other packets have the possibility (however unlikely) of getting large, since there are not fixed length fields like address names in them.

          I would suggest a generic mechanism that can take any packet and encode it into a set of messagingbuffers - in most cases only one buffer would be produced.

          • 3. Re: Handling Large Messages
            Andy Taylor Master

             

            I think we should extend the concept of splitting packets into fragments to other packets too - not just message sends and receives, since other packets have the possibility (however unlikely) of getting large, since there are not fixed length fields like address names in them.


            yeah so the 1st way i suggested would do this. basically the encode method of PAcketImpl would be something like:
            public void encode(MessagingBuffer buffer)
             {
             //The standard header fields
             buffer.putInt(0); //The length gets filled in at the end
             buffer.putByte(type);
             buffer.putLong(responseTargetID);
             buffer.putLong(targetID);
             buffer.putLong(executorID);
             buffer.putInt(correlationId);
             buffer.putBoolean(isLastMessage);
             //if we are a small message
             if(!isMultiPartMessage())
             {
             encodeBody(buffer);
             }
             else
             {
             //else write the body to a cache and for each send only write 1k of body to the message
             if(correlationId == 0)
             {
             bodyCache = buffer.createNewBuffer(1024);
             encodeBody(bodyCache);
             }
             buffer.putBytes(bodyCache.array(), correlationId * 1024, 1024);
             }
            
             //The length doesn't include the actual length byte
             int len = buffer.position() - DataConstants.SIZE_INT;
            
             buffer.putInt(0, len);
            
             buffer.flip();
             }
            


            Then we just keep on sending the same message but with the next part of the body.