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();