Hi !<div><br></div><div>I&#39;ve been using Netty to implement a very simple text-based protocol for a log service, where messages are UTF-8 strings like this:</div><div><br></div><div style="margin-left: 40px;"><font face="&#39;courier new&#39;, monospace">&lt;LOG_FILE_PATH&gt;:&lt;JSON_ENCODED_MESSAGE_DATA&gt;\n</font></div>


<div><br></div><div>For instance</div><div><br></div><div style="margin-left: 40px;"><font face="&#39;courier new&#39;, monospace">hello/world.log:&quot;Hello, World&quot;\n</font></div><div><br></div><div>would append &quot;Hello, World&quot; to the hello/world.log file.</div>


<div><br></div><div>The problem I have is that it seems that some messages get interwoven, basically just as if the server considered two messages as being part of the same one, and intermixing both. My problem is then: how do I ensure that each message is reliably sent, and that the server does not &quot;interweaves&quot; received messages.</div>


<div><br></div><div>The server is implemented using a ChannelPipelineCoverage(&quot;one&quot;) SimpleChannelUpstreamHandler. The message aggregation happens in messageReceived, which works like this:</div><div><br></div>

<div style="margin-left: 40px;">
<span style="font-family: courier new,monospace;">if message contains &quot;\n&quot;</span></div><div style="margin-left: 40px; font-family: courier new,monospace;">   write(buffer)</div><div style="margin-left: 40px; font-family: courier new,monospace;">

else</div><div style="margin-left: 40px; font-family: courier new,monospace;">  buffer append (message)</div><div style="margin-left: 40px; font-family: courier new,monospace;">end<br><br></div><div>with a pipeline setup like this<br>

<br><span style="font-family: courier new,monospace;">        p.addLast(&quot;decoder&quot;, new StringDecoder(CharsetUtil.UTF_8));</span><br><br></div><div>and the client is implemented with the following decoders<br><br>

<span style="font-family: courier new,monospace;">        e.getChannel().getPipeline().addLast(&quot;frameDecoder&quot;, new DelimiterBasedFrameDecoder(65535, Delimiters.lineDelimiter()(0), Delimiters.lineDelimiter()(1)))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">        e.getChannel().getPipeline().addLast(&quot;encoder&quot;,      new StringEncoder(CharsetUtil.UTF_8));</span><br><br>I suppose the problem might be related to the &quot;frameDecoder&quot;, which, to be frank, I don&#39;t remember why I used it. So what would be the best setup for a high-performance (10+K messages/second) client/server for this simple text protocol ? I could use 0MQ for that, but Netty being pure Java, it&#39;s easier to deploy.<br>

<br>Thanks,<br><br> -- Sébastien<br><br></div><div><br>
</div><div><br></div><div><br></div><div><br></div><div><br></div>