if (transformerId == null && targetId == null) {
throw new IllegalStateException("Exchange status is " + ExchangeStatus.DONE
+ " but has no correlation set");
}
// Load the exchange
MessageExchange me = (MessageExchange) store.load(targetId != null ? targetId : transformerId);
done(me);
// Errors must be sent back to the target or transformer
} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
String transformerId = (String) exchange.getProperty(correlationTransformer);
String targetId = (String) exchange.getProperty(correlationTarget);
if (transformerId == null && targetId == null) {
throw new IllegalStateException("Exchange status is " + ExchangeStatus.DONE
+ " but has no correlation set");
}
// Load the exchange
MessageExchange me = (MessageExchange) store.load(targetId != null ? targetId : transformerId);
fail(me, exchange.getError());
// This is a new exchange
} else if (exchange.getProperty(correlationTransformer) == null) {
if (!(exchange instanceof InOnly) && !(exchange instanceof RobustInOnly)) {
fail(exchange, new UnsupportedOperationException("Use an InOnly or RobustInOnly MEP"));
return;
}
// Create exchange for target
MessageExchange tme = getExchangeFactory().createInOutExchange();
transformer.configureTarget(tme, getContext());
// Set correlations
exchange.setProperty(correlationTransformer, tme.getExchangeId());
tme.setProperty(correlationConsumer, exchange.getExchangeId());
tme.setProperty(TRANSFORMER, Boolean.TRUE);
tme.setProperty(CONSUMER_MEP, exchange.getPattern());
// Put exchange to store
store.store(exchange.getExchangeId(), exchange);
// Send in to listener and target
MessageUtil.transferInToIn(exchange, tme);
send(tme);