}
final ValueHolder<FutureTask> futureHolder = new ValueHolder<FutureTask>();
final DeferredMessageSentCallback callback = msgIdAsCorrId ? deferredRequestReplyMap.createDeferredMessageSentCallback() : null;
final CamelJmsTemplate template = (CamelJmsTemplate)getInOutTemplate();
MessageCreator messageCreator = new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
Message message = endpoint.getBinding().makeJmsMessage(exchange, in, session);
message.setJMSReplyTo(replyTo);
requestor.setReplyToSelectorHeader(in, message);
FutureTask future = null;
future = (!msgIdAsCorrId)
? requestor.getReceiveFuture(message.getJMSCorrelationID(), endpoint.getConfiguration().getRequestTimeout())
: requestor.getReceiveFuture(callback);
futureHolder.set(future);
if (LOG.isDebugEnabled()) {
LOG.debug(endpoint + " sending JMS message: " + message);
}
return message;
}
};
if (destinationName != null) {
template.send(destinationName, messageCreator, callback);
} else if (destination != null) {
template.send(destination, messageCreator, callback);
} else {
throw new IllegalArgumentException("Neither destination nor destinationName is specified on this endpoint: " + endpoint);
}
setMessageId(exchange);