private long timeTolive = Message.DEFAULT_TIME_TO_LIVE;
public void setMessageHeaders(Message message, Request request, Hermes hermes, SubmitContext submitContext) {
if (request instanceof AbstractHttpRequest) {
JMSHeaderConfig jmsConfig = ((AbstractHttpRequest<?>) request).getJMSHeaderConfig();
try {
// JMSCORRELATIONID
if (jmsConfig.getJMSCorrelationID() != null && !jmsConfig.getJMSCorrelationID().equals("")) {
message.setJMSCorrelationID(PropertyExpander.expandProperties(submitContext,
jmsConfig.getJMSCorrelationID()));
}
// JMSREPLYTO
if (jmsConfig.getJMSReplyTo() != null && !jmsConfig.getJMSReplyTo().equals("")) {
message.setJMSReplyTo(hermes.getDestination(
PropertyExpander.expandProperties(submitContext, jmsConfig.getJMSReplyTo()), Domain.QUEUE));
}
// TIMETOLIVE
if (jmsConfig.getTimeToLive() != null && !jmsConfig.getTimeToLive().equals("")) {
setTimeTolive(Long.parseLong(PropertyExpander.expandProperties(submitContext,
jmsConfig.getTimeToLive())));
} else {
setTimeTolive(Message.DEFAULT_TIME_TO_LIVE);
}
// JMSTYPE
if (jmsConfig.getJMSType() != null && !jmsConfig.getJMSType().equals("")) {
message.setJMSType(PropertyExpander.expandProperties(submitContext, jmsConfig.getJMSType()));
}
// JMSPRIORITY
if (jmsConfig.getJMSPriority() != null && !jmsConfig.getJMSPriority().equals("")) {
message.setJMSPriority(Integer.parseInt(PropertyExpander.expandProperties(submitContext,
jmsConfig.getJMSPriority())));
} else {
message.setJMSPriority(Message.DEFAULT_PRIORITY);
}
// JMSDELIVERYMODE
if (jmsConfig.getJMSDeliveryMode() != null && !jmsConfig.getJMSDeliveryMode().equals("")) {
int deliveryMode = jmsConfig.getJMSDeliveryMode().equals("PERSISTENT") ? javax.jms.DeliveryMode.PERSISTENT
: javax.jms.DeliveryMode.NON_PERSISTENT;
message.setJMSDeliveryMode(deliveryMode);
} else {
message.setJMSDeliveryMode(Message.DEFAULT_DELIVERY_MODE);
}
} catch (NamingException e) {
SoapUI.logError(
e,
"Message header JMSReplyTo = "
+ PropertyExpander.expandProperties(submitContext, jmsConfig.getJMSReplyTo())
+ "destination not exists!");
} catch (Exception e) {
SoapUI.logError(e, "error while seting message header properties!");
}
}