hi, Denis, try this to see if follows could help you ^^

in Handler which extends HTTP codec
1. generate a messageId and record startTime and something others in a data
struct in this channel attr or in a global data struct
2. decode a http request
3. put the messageId in http request headers


in HttpRequestHandler
1. pull the messageId in httpRequest header
2. record something with messageId
3. do business
4.
response.headers().set(CONNECTION, KEEP_ALIVE);
ctx.write(response).addListener(new GenericFutureListener<Future<? super
Void>>() {
    // this method is called after flush() method
    @Override
    public void operationComplete(Future<? super Void> future) throws
Exception {
        future.isSuccess();
        // do something with messageId
    }
});


2016-11-25 17:52 GMT+08:00 Denis Rossi <[email protected]>:

> Hi,
>
> I'm implementing an HTTP server with netty 4.1.6.Final, and I would like
> to implement an access log.
> This is what I would like to do, considering that I'm trying to never call
> writeAndFlush but just write and flush is called only when a read complete
> event has been fired:
>
>    1. get the start time before the the message is decoded to an
>    HttpRequest (before the HTTP codec)
>    2. get method, protocol, uri, x-forwarded-for and x-forwarded-proto
>    headers immediately after the message has been decoded in a HTTP request
>    3. get response status and content length when I write the HTTP
>    response
>    4. get the response time when I flush
>
> The problem I'm facing is that I cannot keep trace of all those
> informations as channel attributes cause a read operation could happen
> before the flush is called.
>
> Even if I try to keep those information grouped by a messageId set at the
> very first read, I cannot know, when I flush, to which original message I'm
> responding.
>
>
> Does it makes sense? Am I approaching the problem in a wrong way?
>
>
> Thanks for helping.
>
>
> Regards,
>
> Denis Rossi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Netty discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/netty/bd4b6427-7c24-4557-b589-f4381bfe2925%40googlegroups.com
> <https://groups.google.com/d/msgid/netty/bd4b6427-7c24-4557-b589-f4381bfe2925%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/netty/CAFs-Nz0Uo1HCBQ1tVDbbkVet2h9TKSHAcPOwEfKdQCp7Shsn9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to