exchange.setException(e);
}
}
void sendMessage(Exchange exchange, org.apache.camel.Message camelMessage) throws Exception {
Message message = camelMessage.getBody(Message.class);
log.debug("Sending FIX message: {}", message);
SessionID messageSessionID = getEndpoint().getSessionID();
if (messageSessionID == null) {
messageSessionID = MessageUtils.getSessionID(message);
}
Session session = getSession(messageSessionID);
if (session == null) {
throw new IllegalStateException("Unknown session: " + messageSessionID);
}
Callable<Message> callable = null;
if (exchange.getPattern().isOutCapable()) {
MessageCorrelator messageCorrelator = getEndpoint().getEngine().getMessageCorrelator();
callable = messageCorrelator.getReply(getEndpoint().getSessionID(), exchange);
}
if (!session.send(message)) {
throw new CannotSendException("Cannot send FIX message: " + message.toString());
}
if (callable != null) {
Message reply = callable.call();
exchange.getOut().setBody(reply);
}
}