I've tried using flip on the decoder on the IoBuffer and it solves my looping issue, so this now is my currently implementation:
This is my Encoder: public class ServiceEnvironmentMessageEncoder extends ProtocolEncoderAdapter { public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws EncoderException { ServiceEnvironmentMessage serviceEnvironmentMessage = (ServiceEnvironmentMessage)message; ByteBuffer buffer = null; buffer = serviceEnvironmentMessage.encode(buffer); buffer.rewind(); IoBuffer ioBuffer = IoBuffer.wrap(buffer); out.write(ioBuffer); } } And my decoder: public class ServiceEnvironmentMessageDecoder extends CumulativeProtocolDecoder { protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws DecoderException { IoBuffer inFlipped = in.flip(); // MINA 2.0.4 implementation byte[]inArray = inFlipped.array(); // MINA 2.0.4 implementation /* MINA 2.0.0-M3 Implementation byte[]inArray = in.array(); */ out.write(decode(inArray)); return true; } private ServiceEnvironmentMessage decode(byte[] stream) throws DecoderException { ByteBuffer bb = ByteBuffer.wrap(stream); ServiceEnvironmentMessageContainer container = new ServiceEnvironmentMessageContainer(ServiceEnvironmentMessageGrammar.getInstance()); decoder.decode(bb, container); ServiceEnvironmentMessage message = container.getServiceEnvironmentMessage(); container.clean(); return message; } } So, for my original issue - under high load (4000+ transactions per second) my responses are timing out on the request side, is there performance tweaking i can do to improve performance? I see in the FAQs under troubleshooting: "I get OutOfMemoryError or response timeout and connection reset under heavy load." There is a recommendation to switch buffer type to heap. How can i tell what type i'm already using and how to set it to 'heap' type? It says to do this, but make little sense to me: ByteBuffer.setUseDirectBuffers(false); ByteBuffer.setAllocator(new SimpleByteBufferAllocator()); Brendan -----Original Message----- From: Emmanuel Lécharny [mailto:elecha...@gmail.com] Sent: 23 July 2012 23:03 To: users@mina.apache.org Subject: Re: Upgrade considerations between MINA 2.0.0-M3 to 2.0.4 Le 7/23/12 7:13 PM, Brendan Crowley a écrit : > No i don't flip > > This is the decode method: > > private ServiceEnvironmentMessage decode(byte[] stream) throws > DecoderException { > ByteBuffer bb = ByteBuffer.wrap(stream); > > ServiceEnvironmentMessageContainer container = new > ServiceEnvironmentMessageContainer(ServiceEnvironmentMessageGrammar.getInstance()); > decoder.decode(bb, container); > > ServiceEnvironmentMessage message = > container.getServiceEnvironmentMessage(); > > // Clean the container for the next decoding > container.clean(); > > return message; > } > > I don't understand how to flip the buffer after decoding? I could invoke > bb.flip(); but this would have no effect. This is not here that th ebuffer should be flipped. You already have extracted the byte[] out of the IoBuffer. I need to see the whole code in order to provide some help (at least, the way you implementd the decoder) -- Regards, Cordialement, Emmanuel Lécharny www.iktek.com