sendMessage(exchange, exchange.getIn());
}
void sendMessage(Exchange exchange, org.apache.camel.Message camelMessage) throws InterruptedException {
try {
Message message = camelMessage.getBody(Message.class);
log.debug("Sending FIX message: {}", message);
SessionID messageSessionID = sessionID;
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()) {
QuickfixjEndpoint endpoint = (QuickfixjEndpoint) getEndpoint();
MessageCorrelator messageCorrelator = endpoint.getEngine().getMessageCorrelator();
callable = messageCorrelator.getReply(endpoint.getSessionID(), exchange);
}
session.send(message);
if (callable != null) {
Message reply = callable.call();
exchange.getOut().setBody(reply);
}
} catch (Exception e) {
exchange.setException(e);
}