The 100% CPU load can usually be avoided if you use some stratigically
placed Sleep() commands. But you're right, the SumUp example shows the way
to go (using a codec layer). The session.setAttribute can be used for your
#2 concern. In my own project I've got a state object attached to the
session that tells me something about the current decoding state, already
processed bytes in buffer etc. That state object is updated in my decode
method and allows me to process packets in whatever sequence.
In the end, what helped me the most, was carefully walking through the SumUp
example. Together with the session.setAttribute, it has everything you'll
need.
--
Jeroen Brattinga
2007/3/2, mat <[EMAIL PROTECTED]>:
I think i made a mistake to do my own protocol encode and decode in
IOHandler messageReceived which is supposed to handle the business logic.
It
causes my application eats up 100% CPU time when large size of incoming
message. I guess I didn't handle the decoding well.
1) Therefore, I believe the existing of codec layer is for the performance
enhancement(handled the encoding and decoding issue in codec filter,
correct
me if i am wrong)
2) I read the source of SumUp example and I wonder how can I handle the
hundred of sessions in customer codec filter. For instance, if I get the
packets from one session however the packets are not complete for whole
message. Should I put that into the session.setAttribute
('AlreadyGotPacket")?
and next time, just getAttribute('AlreadyGotPacket")
Thanks.