"Long running" handlers

Brad Harvey harveybm at gmail.com
Sat Mar 6 08:23:30 EST 2010


Which Executor are you using in your ExecutionHandler? 

eg try
http://www.jboss.org/file-access/default/members/netty/freezone/api/3.1/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.html
rather than the ordered variation.

infectedrhytms wrote:
> Thanks! It seems to be working, but I still see an issue.
>
> I'm trying to implement a server with netty using a persistent connection.
> I.e: The client will connect once and send all of it's messages over that 1
> connection. So now back to square one. If I implement 1 client connection 1
> 1 request and close the socket with
> future.addListener(ChannelFutureListener.CLOSE); I get no problem.
>
> Here is the log of my C++ application connecting to my netty server...
>
>
> Client opens 1 connection sends 5 messages... Server takes about 500ms to
> process each request...
>
> [15:38:26.215] Thread1, Send to netty id 1
> [15:38:26.215] Thread1, Send to netty finished
> [15:38:26.215] Thread2, Send to netty id 2
> [15:38:26.215] Thread2, Send to netty finished
> [15:38:26.215] Thread3, Send to netty id 3
> [15:38:26.215] Thread3, Send to netty finished
> [15:38:26.215] Thread4, Send to netty id 4
> [15:38:26.215] Thread4, Send to netty finished
> [15:38:26.215] Thread5, Send to netty id 5
> [15:38:26.215] Thread5, Send to netty finished
> [15:38:26.715] Thread1, Received head length from bank: Length=211 (d3)
> [15:38:26.731] Response incoming...
> [15:38:26.731] Response is for id 1
> [15:38:27.231] Response incoming...
> [15:38:27.231] Response is for id 2
> [15:38:27.731] Response incoming...
> [15:38:27.731] Response is for id 3
> [15:38:28.231] Response incoming...
> [15:38:28.231] Response is for id 4
> [15:38:28.731] Response incoming...
> [15:38:28.731] Response is for id 5...
>
> So as you can see the 5 messages where all sent at the same time, but then
> each response came in 500ms after each other as if they where queued. If I
> implement 1 client connection  per 1 request and close the connection in the
> handler everything is ok. But I need to keep the connection open.
>
> This is my handler implementation
>
> public class MyHandler extends SimpleChannelHandler {
> 	String request = (String) e.getMessage();
>
> // Do some stuff here...
>
> 	ChannelFuture future = e.getChannel().write(response);
> 		
> 	// Do not close we need to keep 1 connection per client
> 	//future.addListener(ChannelFutureListener.CLOSE);
> }
>
>
>
>
>
>
>   


More information about the netty-users mailing list