java ee - Tutorials on Core netty and Protobuf -
i working distributed systems(java/ee,netty,protobuf).wondering how send document client server , store in server database.
sending string seems simple, how go sending big file. need chunk small messages , send over.
any tutorials, on how work documents.
i assuming you've done boilerplate code portion of netty, have running server protocol buffers interceptors set , you've generated protocol buffers related classes. if need these steps, please so, edit , add them.
first thing first, serialising big chunks of data (anything may temper heap) no protobuf. simple thing(s) do;
1- byte stream (buffered) of content 2- construct protobuf message (ex: contentchunk) , add minimum 2 fields representing chunk order , chunk part (depending on concurrent traffic, chunk parts should not crack heap optimise size wisely) itself. chunk order server side reconstruct chunk in right order. 3- can add additional field inner framing of chunks or pass total length in first message. 4- implement outer framing main protocol message. chunks , form final content , persist it.
for 4th item, check netty's current framing support.
protobufvarint32framedecoder protobufvarint32lengthfieldprepender
your pipeline should like;
bootstrap.setpipelinefactory (new channelpipelinefactory () { @override public channelpipeline getpipeline () throws exception { channelpipeline pipeline = channels.pipeline (); pipeline.addlast ("framedecoder", new protobufvarint32framedecoder ()); pipeline.addlast ("protobufdecoder", new protobufdecoder (yourprotocol.protocolmessage.getdefaultinstance ())); pipeline.addlast ("frameencoder", new protobufvarint32lengthfieldprepender ()); pipeline.addlast ("protobufencoder", new protobufencoder ()); pipeline.addlast ("handler", new clienteventhandler ()); return pipeline; } });
Comments
Post a Comment