Channel.write() not working in a loop

"이희승 (Trustin Lee)" trustin at gmail.com
Mon Nov 22 22:24:06 EST 2010


Note that Netty's I/O thread calls your pipeline directly, which means
it will not do any I/O until your handler returns.  Therefore, you need
to make sure that your loop does return quickly so that it doesn't block
I/O.

HTH

maxypayne wrote:
> The requirement is to send a request (channel.write()), check the response
> for a particular attribute. Compare it against the request attribute. If
> they don't match discard the response and send the request again. (Please
> find the code snippet below.)
> 
> The problem is messageRecevied() gets invoked for the first request but not
> for the subsequent request. What am I doign wrong?
> 
>     public Response call() {
>         logger.info("request = " + request);
>         // Send the request to the remote server
>         Response response = null;
>         while (true) {
>             channel.write(
>                     request,
>                     new InetSocketAddress(MessageReader
>                             .getString("remoteipaddress"), new Integer(
>                             MessageReader.getString("remoteport"))));
>             response = obtainResponse(); // Get it from messageREceived
>             /*
>              * Ensure the tx id of the response is the same as the tx id of
> the
>              * request. If not, we need to discard the response and re-issue
> a
>              * request.
>              */
>             if (request.getIdTransazione() != response.getIdTransazione()) {
>                 response = null;
>                 continue;
>             }
>             return response;
>         }
>     }
> 
> 

-- 
Trustin Lee - http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 290 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20101123/b12e4a2a/attachment.bin 


More information about the netty-users mailing list