This issue still confuses me, I'm unable to grasp why the contents can be
fetched for small payloads but not for large. And if I set the message
output stream in an earlier interceptor, I can fetch the same instance of
the object but it is still blank. And one would think that in PRE_STREAM,
the contents should be present(?)

On Thu, Jun 6, 2019 at 1:47 PM Nicklas Karlsson <[email protected]> wrote:

> Hi,
>
> I'm trying to do message tranformations based on examples from Stack
> Overflow etc and I have something on 3.0.4 like
>
> public MessageXMLDecodeOutInterceptor() {
>    super(Phase.PRE_STREAM);
> }
>
> public void handleMessage(Message message) {
>    try (OutputStream outStream = message.getContent(OutputStream.class);
> CachedOutputStream cachedStream = new CachedOutputStream();) {
>       message.setContent(OutputStream.class, cachedStream);
>       message.put(Message.ENCODING, charset.name());
>       message.getInterceptorChain().doIntercept(message);
>       cachedStream.flush();
>       String origMessage = IOUtils.toString(cachedStream.getInputStream(),
> charset);
>       String newMessage = // modify the message
>       IOUtils.write(header, outStream, charset);
>       IOUtils.write(newMessage, outStream, charset);
>    } catch (IOException e) {
>       logger.errorf("Could not transform message", e);
>    }
> }
>
> and it works until the message i large (~200k?), then suddenly the
> origMessage is "". Are large messages somehow cached/handled differently?
>
> Thanks in advance,
>   Nik
>
> --
> Nicklas Karlsson, +358 40 5062266
> Vaakunatie 10 as 7, 20780 Kaarina
>


-- 
Nicklas Karlsson, +358 40 5062266
Vaakunatie 10 as 7, 20780 Kaarina

Reply via email to