use of org.springframework.jms.core.JmsOperations in project camel by apache.
the class JmsConfiguration method createInOutTemplate.
/**
* Creates a {@link JmsOperations} object used for request/response using a request timeout value
*/
public JmsOperations createInOutTemplate(JmsEndpoint endpoint, boolean pubSubDomain, String destination, long requestTimeout) {
JmsOperations answer = createInOnlyTemplate(endpoint, pubSubDomain, destination);
if (answer instanceof JmsTemplate && requestTimeout > 0) {
JmsTemplate jmsTemplate = (JmsTemplate) answer;
jmsTemplate.setExplicitQosEnabled(true);
// prefer to use timeToLive over requestTimeout if both specified
long ttl = timeToLive > 0 ? timeToLive : requestTimeout;
if (ttl > 0 && !isDisableTimeToLive()) {
// only use TTL if not disabled
jmsTemplate.setTimeToLive(ttl);
}
jmsTemplate.setSessionTransacted(isTransactedInOut());
if (isTransactedInOut()) {
jmsTemplate.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED);
} else {
if (acknowledgementMode >= 0) {
jmsTemplate.setSessionAcknowledgeMode(acknowledgementMode);
} else if (acknowledgementModeName != null) {
jmsTemplate.setSessionAcknowledgeModeName(acknowledgementModeName);
} else {
// default to AUTO
jmsTemplate.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
}
}
}
return answer;
}
Aggregations