try {
JMSBindingData bindingData = new JMSBindingData(message);
final String operation = _selector != null ? _selector.selectOperation(bindingData).getLocalPart() : null;
SynchronousInOutHandler replyHandler = new SynchronousInOutHandler();
Exchange exchange = createExchange(operation, replyHandler);
exchange.send(_composer.compose(bindingData, exchange));
if (_connectionFactory == null) {
return;
}
// Process replyTo and faultTo if ConnectionFactory is available
Context context = exchange.getContext();
Connection connection = null;
try {
if (_userName != null) {
connection = _connectionFactory.createConnection(_userName, _password);
} else {
connection = _connectionFactory.createConnection();
}
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination faultTo = getFaultToDestinationFromContext(session, context);
Destination replyTo = getReplyToDestinationFromContext(session, context);
if (faultTo != null && ExchangeState.FAULT.equals(exchange.getState())) {
if (exchange.getMessage() != null) {
sendJMSMessage(session, faultTo, exchange, getOutputMessageTypeFromContext(context));
}
} else if (replyTo != null && ExchangePattern.IN_OUT.equals(exchange.getPattern())) {
exchange = replyHandler.waitForOut();
if (exchange.getMessage() != null) {
sendJMSMessage(session, replyTo, exchange, getOutputMessageTypeFromContext(context));
}
}
} finally {
if (connection != null) {