/** * Sends a reply message if the exchange has a valid message in the out or * in fields (in that order). * * @param correlationId the optional correlation ID to set on the out going * message * @param replyToDestination the reply to destination * @param camelExchange the exchange containing the message to send as the * reply */ private void sendReply(String correlationId, String replyToDestination, Exchange camelExchange) { Message camelMsg = camelExchange.hasOut() ? camelExchange.getOut() : camelExchange.getIn(); if (camelMsg != null) { try { HazelcastMQMessage msg = messageConverter.fromCamelMessage(camelMsg); msg.getHeaders().remove(org.mpilone.hazelcastmq.core.Headers.REPLY_TO); msg.setDestination(replyToDestination); msg.setCorrelationId(correlationId); mqContext.createProducer(replyToDestination).send(msg); } catch (Throwable ex) { camelExchange.setException(ex); } } } }