4 Replies Latest reply on Jul 4, 2008 7:44 AM by Tim Fox

    MessagingBuffer implementation leaking into MessageImpl

    Andy Taylor Master

      Currently when a message is encoded or decoded, the methods are called from The transport layer and the MessagingBuffer implementation is specific to this transport. The transport will encode/decode the messages by using the MessagingCodecImpl and this in turn delegates down to a specific Packet depending on the PacketType. When a Packet encodes/decodes itself it should not need to know anything about the MessagingBuffer implementation.

      However I've noticed that in MessageImpl the body of the message is also a MessagingBuffer and in the constructor and the decode method we default to the Mina Implementation. This all works at present since we only use Mina but will fail when the ByteBufferWrapper or the new Netty implementation when Trustin adds it.

      the method clearBody() in JbossBytesMessage and JBossStreamMessage also assumes an implementation.

      1 solution would be to add a new class 'MessageBody' that uses an underlying ByteBuffer and when the message is encoded/decoded we call buffer.put(byteBuffer) etc.

      I'm not 100% sure what the effect on performance will be but i was thinking that using a direct ByteBuffer will mean no copying is done.

      thoughts?