Hmm, that's what I thought but I think I'm using it wrong -- I think the client should use an encoder rather than a decoder, and that the decoder should go in the server.<div><br></div><div>Thanks anyway :)</div><div>
<br></div><div> -- Sébastien<br><br><div class="gmail_quote">2010/11/2 Christian Migowski <span dir="ltr"><<a href="mailto:chrismfwrd@gmail.com">chrismfwrd@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
the use of the DelimiterbasedFrameDecoder ensures that your<br>
messageReceived method only gets complete "frames", that is lines in<br>
your case. So you don't need to check and buffer in your<br>
messagereceived method. Also, but I am not 100% sure on this, I would<br>
assume that the framedecoder removes the delimiters from the received<br>
data, so that your code would not work very well anyway.<br>
<br>
regards,<br>
christian!<br>
<br>
<br>
<br>
2010/11/2 Sébastien Pierre <<a href="mailto:sebastien.pierre@gmail.com">sebastien.pierre@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hi !<br>
> I've been using Netty to implement a very simple text-based protocol for a<br>
> log service, where messages are UTF-8 strings like this:<br>
> <LOG_FILE_PATH>:<JSON_ENCODED_MESSAGE_DATA>\n<br>
> For instance<br>
> hello/world.log:"Hello, World"\n<br>
> would append "Hello, World" to the hello/world.log file.<br>
> The problem I have is that it seems that some messages get interwoven,<br>
> basically just as if the server considered two messages as being part of the<br>
> same one, and intermixing both. My problem is then: how do I ensure that<br>
> each message is reliably sent, and that the server does not "interweaves"<br>
> received messages.<br>
> The server is implemented using a ChannelPipelineCoverage("one")<br>
> SimpleChannelUpstreamHandler. The message aggregation happens in<br>
> messageReceived, which works like this:<br>
> if message contains "\n"<br>
> write(buffer)<br>
> else<br>
> buffer append (message)<br>
> end<br>
><br>
> with a pipeline setup like this<br>
><br>
> p.addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));<br>
><br>
> and the client is implemented with the following decoders<br>
><br>
> e.getChannel().getPipeline().addLast("frameDecoder", new<br>
> DelimiterBasedFrameDecoder(65535, Delimiters.lineDelimiter()(0),<br>
> Delimiters.lineDelimiter()(1)))<br>
> e.getChannel().getPipeline().addLast("encoder", new<br>
> StringEncoder(CharsetUtil.UTF_8));<br>
><br>
> I suppose the problem might be related to the "frameDecoder", which, to be<br>
> frank, I don't remember why I used it. So what would be the best setup for a<br>
> high-performance (10+K messages/second) client/server for this simple text<br>
> protocol ? I could use 0MQ for that, but Netty being pure Java, it's easier<br>
> to deploy.<br>
><br>
> Thanks,<br>
><br>
> -- Sébastien<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> netty-users mailing list<br>
> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
><br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a></blockquote></div><br></div>