I just got started with Netty and I'm trying to understand how to set up my
app. Basically I need to take in the raw bytes, parse the message type, do
some application logic like talking to a database, and then either return
the requests in some scenarios, or talk to other systems. I created a
subclass of ByteToMessageDecoder and I parse the message type, and get the
payload I want properly. Something that looks like:
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object>
out) {
// find the message type from first bit
int messageType = in.getByte(0);
if (messageType == MessageType.VERSION) {
out.add(createVersionMessageType(in.readBytes())
} else if (messageType == MessageType.INFO) {
out.add(createInfoMessageType(in.readBytes())
}
//... more message types ....
}
Then do I create MessageToMessageDecoder<MessageType> in order for members of
the ChannelPipeline to ignore messages of the types it does not care about, and
handle the types it does care about?
Is there a "best practice" on where I should do my application logic like
talking to a database and validating data?
Thanks
--
You received this message because you are subscribed to the Google Groups
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/netty/70e09b30-dd78-4cf0-9095-9186a410cbb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.