Progressively decode a message (and other questions)
Ashwin Jayaprakash
ashwin.jayaprakash at gmail.com
Sun Nov 14 14:16:26 EST 2010
Hi, I'm a Netty noob and I have some basic questions. I'm still exploring
the API so be gentle :)
Is there a way to incrementally decode a message from a ChannelBuffer? Like
this:
1. Read some key integer fields
2. If not interested, discard message - do not decode the rest of the
message. Just discard it. How do I cancel further downstream codecs?
There are some other restrictions:
- I do not want to do a getBytes(xx) on the message and make a copy of
the remaining message from the buffer to a byte[] . I know people would
suggest this because it's the easiest workaround by doing the decode on my
own from a byte[]. I want to avoid copying the bytes again and again from
layer to layer
- If I used slice() I suppose it would help avoid a copy?
- Are these channelbuffers pooled? How long can I hang on to the
MessageEvent, Channel or Channelbuffer instance? Would I be starving some
other component/connection?
- FYI, I had asked a similar question on the Google Protobuf forum -
http://groups.google.com/group/protobuf/browse_thread/thread/4563998c85d01882/1859fe2958485da2
- If I want to re-route my server request from 1 server to another server
- read some bits and then decide to "forward" the message to another server,
can I just do a zero-copy of the original bytes and send them to another
server? You see - like a Hibernate disconnected session or a SQL
Disconnected row set?
- The server now becomes a client to another server, so can I just use
the same buffers and "transfer" them to the other handler that
is talking to
the final server?
Confused? :)
Super clean APIs though, I'm impressed.
Regards,
Ashwin Jayaprakash.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20101114/af1c0b6d/attachment.html
More information about the netty-users
mailing list