Hi Daniel,

thx a lot for the tip. In fact I discovered this solution five minutes
after asking the question ;)

FYI for the input stream I use RECEIVE phase to register the wrapper and
INVOKE phase to read bytes read count.
For the output stream I use PRE_STREAM phase to register the wrapper and
POST_STREAM phase to read bytes written count.

Cheers,
Przemyslaw


On Tue, Jun 10, 2014 at 9:30 PM, Daniel Kulp <[email protected]> wrote:

>
> On Jun 10, 2014, at 10:27 AM, Przemyslaw Bielicki <[email protected]>
> wrote:
>
> > I need to know the input and output message size in my interceptors.
> >
> > I assume that "Content-Length" is not set in the request i.e.
> > (Transfer-Encoding = chunked), so I cannot take the in length from the
> HTTP
> > header - it must be really "computed".
> >
> > Additional difficulty is that I don't want to serialize incoming and
> > outgoing messages toString() as it will be a performance issue.
> >
> > Is there any way to get these sizes from the Input/OutputStream? Is
> there a
> > way to inject my custom stream wrappers that will be counting number of
> > bytes read/written?
>
> You would need to write an interceptor that would live fairly early in the
> interceptor chain that would do something like:
>
> InputStream in = message.getContent(InputStream.class);
> in = new MyLengthRecordingStream(in);
> message.setContent(InputSteam.class, in);
>
> The rest of the processing would then use your input stream and at the end
> of all the processing, you would have the length.
>
>
> --
> Daniel Kulp
> [email protected] - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>
>

Reply via email to