final JMSMessageHeadersType messageProperties = (JMSMessageHeadersType)outMessage
.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
JMSMessageHeadersType inMessageProperties = (JMSMessageHeadersType)inMessage
.get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
JMSUtils.initResponseMessageProperties(messageProperties, inMessageProperties);
JmsTemplate jmsTemplate = JMSFactory.createJmsTemplate(jmsConfig, messageProperties);
// setup the reply message
final javax.jms.Message request = (javax.jms.Message)inMessage
.get(JMSConstants.JMS_REQUEST_MESSAGE);
final String msgType;
if (isMtomEnabled(outMessage)
&& !jmsConfig.getMessageType().equals(JMSConstants.TEXT_MESSAGE_TYPE)) {
//get chance to set messageType from JMSConfiguration with MTOM enabled
msgType = jmsConfig.getMessageType();
} else if (request instanceof TextMessage) {
msgType = JMSConstants.TEXT_MESSAGE_TYPE;
} else if (request instanceof BytesMessage) {
msgType = JMSConstants.BYTE_MESSAGE_TYPE;
} else {
msgType = JMSConstants.BINARY_MESSAGE_TYPE;
}
if (JMSConstants.TEXT_MESSAGE_TYPE.equals(msgType) && isMtomEnabled(outMessage)) {
org.apache.cxf.common.i18n.Message msg =
new org.apache.cxf.common.i18n.Message("INVALID_MESSAGE_TYPE", LOG);
throw new ConfigurationException(msg);
}
Destination replyTo = getReplyToDestination(jmsTemplate, inMessage);
if (request.getJMSExpiration() > 0) {
TimeZone tz = new SimpleTimeZone(0, "GMT");
Calendar cal = new GregorianCalendar(tz);
long timeToLive = request.getJMSExpiration() - cal.getTimeInMillis();
if (timeToLive < 0) {
getLogger()
.log(Level.INFO, "Message time to live is already expired skipping response.");
return;
}
}
getLogger().log(Level.FINE, "send out the message!");
jmsTemplate.send(replyTo, new MessageCreator() {
public javax.jms.Message createMessage(Session session) throws JMSException {
javax.jms.Message reply = JMSUtils.createAndSetPayload(replyObj, session, msgType);
reply.setJMSCorrelationID(determineCorrelationID(request));