MessageExchangeSendContext context = sendEvent.getMessageExchangeSendContext();
if (log.isDebugEnabled()) {
log.debug("Enter: HandlerMessageExchange.Listener::onSend");
}
MessageExchangeEventListener listener =
context.getMessageExchangeEventListener();
try {
MessageContext msgContext =
context.getMessageContext();
MessageExchangeCorrelator correlator =
context.getMessageExchangeCorrelator();
if (handler instanceof TargetedChain) {
((TargetedChain)handler).getPivotHandler().invoke(msgContext);
} else {
handler.invoke(msgContext);
}
RECEIVE.put(correlator, context);
} catch (Exception exception) {
if (listener != null) {
MessageFaultEvent faultEvent = new MessageFaultEvent(
context.getMessageExchangeCorrelator(),
exception);
listener.onEvent(faultEvent);
}
} finally {
if (log.isDebugEnabled()) {
log.debug("Exit: HandlerMessageExchange.Listener::onSend");
}