<p>Hello. I guess it also depends on how complex your protocol is. Personally, I am using a decoder that switches between the different possible ones based on state. It gets the job done. </p>
<div class="gmail_quote">On 02-Jun-2011 6:33 PM, &quot;alex77&quot; &lt;<a href="mailto:alejandro.domenech@citi.com">alejandro.domenech@citi.com</a>&gt; wrote:<br type="attribution">&gt; Hi everyone.<br>&gt; <br>&gt; I&#39;m quite new to Netty and I&#39;ve spent the last week looking for information<br>
&gt; and examples about how to implement a client-server communication protocol<br>&gt; using Netty and protobuf that supports multiple protobuf messages. As<br>&gt; everyone else, I took a look to the example in the doc, but as usual, the<br>
&gt; protocol only contains one single protobuf message.<br>&gt; <br>&gt; I&#39;ve found some posts with suggestions about using an envelope message that<br>&gt; will contain the actual protobuf data making use of extensions, and also an<br>
&gt; alternative suggesting to write a protocol that will prepend the message<br>&gt; type, the length and then the actual protobuf data, so on reception you<br>&gt; could use a DecoderEmbedder that will instanciate the proper ProtobufDecoder<br>
&gt; depending on the message type.<br>&gt; <br>&gt; Also I saw some recent code contribution trying to implement a generic<br>&gt; decoder that will accept in the constructor a map of ProtobufDecoders (or a<br>&gt; list and build the map from it) to try to figure out what&#39;s the right one to<br>
&gt; use depending on the message type.<br>&gt; <br>&gt; All these seem to be attempts or suggstions, and I was wondering if there&#39;s<br>&gt; a proper way (the official Netty way) to solve this type of problem, as I<br>
&gt; guess it&#39;s quite common. Is there any plan to add support in a future<br>&gt; release a decoder to do this demultiplexing functionality?<br>&gt; <br>&gt; Not sure the solution Trustin pointed <br>&gt; <a href="http://www.jboss.org/netty/community.html#nabble-td3931395">http://www.jboss.org/netty/community.html#nabble-td3931395</a> here  is a good<br>
&gt; one, as it instanciates a new DecoderEmbedder with a new instance of the<br>&gt; concrete protobuf decoder every time we parse the body of a message. Indeed<br>&gt; it shows the general idea, but sure there&#39;s an efficient way to solve this<br>
&gt; problem.<br>&gt; <br>&gt; Many thanks in advance!<br>&gt; <br>&gt; --<br>&gt; View this message in context: <a href="http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Netty-and-protobuf-protocol-with-complex-messages-tp6431047p6431047.html">http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Netty-and-protobuf-protocol-with-complex-messages-tp6431047p6431047.html</a><br>
&gt; Sent from the Netty User Group mailing list archive at Nabble.com.<br>&gt; _______________________________________________<br>&gt; netty-users mailing list<br>&gt; <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/netty-users">https://lists.jboss.org/mailman/listinfo/netty-users</a><br></div>