public void exchangeSent(ExchangeEvent event) {
try {
MessageExchange exchange = event.getExchange();
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
OutputStream os = getOutputStream(exchange);
NormalizedMessage in = exchange.getMessage("in");
if (StreamSource.class.isAssignableFrom(in.getContent().getClass())) {
StreamSource original = (StreamSource) exchange.getMessage("in").getContent();
TeeInputStream tis = new TeeInputStream(original.getInputStream(), os);
exchange.getMessage("in").setContent(new StreamSource(tis));
} else {
MessageUtil.enableContentRereadability(in);
SourceTransformer transformer = new SourceTransformer();
transformer.toResult(in.getContent(), new StreamResult(os));
}
}
} catch (IOException e) {
LOG.error(String.format("Error occurred while storing message %s", event.getExchange().getExchangeId()), e);
} catch (TransformerException e) {