} catch(Throwable t) {
exchange.setException(t);
}
//Send a reply if one was requested
Address replyToAddress = amqpMessage.getMessageProperties().getReplyToAddress();
if(replyToAddress != null && endpoint.isAutoReply()) {
org.apache.camel.Message outMessage = exchange.getOut();
SpringAMQPMessage replyMessage = new SpringAMQPMessage(outMessage);
// Camel exchange will contain a non-null exception if an unhandled exception has occurred,
// such as when using the DefaultErrorHandler with default configuration, or when
// using the DeadLetterChannel error handler with an OnException handled=false override.
// Exchange will not contain an exception (via getException()) if the exception has been handled,
// such as when using the DeadLetterChannel error handler with default configuration, but
// the Exchange property EXCEPTION_CAUGHT will contain the handled exception.
if (exchange.getException() != null) {
replyMessage.setHeader(SpringAMQPMessage.IS_EXCEPTION_CAUGHT, true);
replyMessage.setBody(exchange.getException());
} else if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
replyMessage.setHeader(SpringAMQPMessage.IS_EXCEPTION_CAUGHT, true);
replyMessage.setBody(exchange.getProperty(Exchange.EXCEPTION_CAUGHT));
}
exchange.setOut(replyMessage); //Swap out the outbound message
try {
endpoint.getAmqpTemplate().send(replyToAddress.getExchangeName(), replyToAddress.getRoutingKey(), replyMessage.toAMQPMessage(msgConverter));
} catch(AmqpConnectException e) {
LOG.error("AMQP Connection error, marking this connection as failed");
onClose(null);
}
}