For some unknown reason, you are sending every mails twice. Could you check that please ?

Le 7/24/12 2:13 PM, Brendan Crowley a écrit :
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;
     }
}

Not sure why you transform the IoBuffer to an array, to transform it back to a ByteBuffer...

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?

Depends. Have you used a profiling to see where the time is consummed ?

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.
Default buffers are heap buffers.
  How can i tell what type i'm already using and how to set it to 'heap' type?
It's already set to heap.

It says to do this, but make little sense to me:
ByteBuffer.setUseDirectBuffers(false);
ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

Don't use direct buffer. This is genrally not a good idea...


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to