Use exchange.getMessage()
And if you really want to use IN or OUT then check with exchange.hasOut() first On Wed, Jul 17, 2019 at 9:41 AM Wang Yan <wyan...@gmail.com> wrote: > > According to document ( > https://camel.apache.org/using-getin-or-getout-methods-on-exchange.html), > when we modify body of exchange, we should use exchange.getIn().setBody() > instead of exchange.getOut().setBody() > > It ususally works. but for OnException block, it does not work , I have to > use exchange.getOut().setBody > Any hints are more than suggest or hints are more than welcome! > > > > > > onException(Exception.class).convertBodyTo(String.class).log(LoggingLevel.INFO, > .process(exchange -> { > exchange.getIn().setHeader("Content-Type", "text/xml; charset=UTF-8"); > exchange.getOut().setBody(" Error happend , please contact Admin "); > //exchange.getIn().setBody(" Error happend , please contact Admin "); -> > exchange.getIn().setBody does not work here!!! > }).handled(true).end(); -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2