java - In Mule how could I log the http response without changing the original output stream -


my mule http call , response client, want log http call result, status code , response body. @ first log #[payload], it's stream, know <object-to-string-transformer/> works, don't want change response, put transformer enricher, result still changed, why?

my code:

<http:outbound-endpoint exchange-pattern="request-response" address="http://#[payload]" doc:name="call service in pool"/> <enricher source="#[payload]" target="#[flowvars['responsebody']]" doc:name="message enricher">     <object-to-string-transformer doc:name="object string"/> </enricher> <logger level="info" doc:name="log response" message="response, http status: #[message.inboundproperties['http.status']], body: #[flowvars['responsebody']], org: #[payload]"/> 

log output:

org.mule.api.processor.loggermessageprocessor: response, http status: 200, body: {"groupid":"group1", "formparam":"null"}, org: org.mule.transport.http.releasinginputstream@51dfd9b8 

client receives no body:

http/1.1 200 ok content-type: application/json date: sat, 24 aug 2013 10:55:49 +0800 server: mule ee core extensions/3.4.0 x-mule_session: ro0abxnyacnvcmcubxvszs5zzxnzaw9ulkrlzmf1bhrndwxlu2vzc2lvbi7rdtew7ggkawaewgafdmfsawrmaa1mbg93q29uc3rydwn0daamtg9yzy9tdwxll2fwas9jb25zdhj1y3qvrmxvd0nvbnn0cnvjddtmaajpzhqaekxqyxzhl2xhbmcvu3ryaw5no0wad3nly3vyaxr5q29udgv4dhqaj0xvcmcvbxvszs9hcgkvc2vjdxjpdhkvu2vjdxjpdhldb250zxh0o3hwaxb0acrhzwfhodzjos0wyzy4ltexztmtyjhkzs0xntqzzdiwnjfknwzwc3iajwphdmeudxrpbc5db2xszwn0aw9ucyrtew5jahjvbml6zwrnyxabc/kjs0s5ewmaakwaaw10aa9mamf2ys91dglsl01hcdtmaavtdxrlehqaekxqyxzhl2xhbmcvt2jqzwn0o3hwc3iajg9yzy5tdwxllnv0awwuq2fzzuluc2vuc2l0axzlsgfzae1hcj3r2e9nrc4aawaaehb3dd9aaaaaaaaqaaaaahhxah4acxh4 x-mule_encoding: utf-8 transfer-encoding: chunked connection: close 

this standard behavior of streams: once consumed it, it's consumed and, unless reset it, stays consumed no more data available.

you can try using mark() before logging reset() after (in mel expression components) there no guarantee actual stream implementation produced mule supports these methods.

read inputstream javadoc more information.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -