int priority = defaultPriority;
long timeToLive = defaultTimeToLive;
for(Map.Entry<String, DataElement> entry : props.entrySet() ) {
String propName = entry.getKey();
DataElement value = entry.getValue();
final String headerPrefix = "jms.header.out.";
final String propertyPrefix = "jms.property.out.";
if( propName.startsWith(headerPrefix) ) {
String headerName = propName.substring(headerPrefix.length());
if ( headerName.equalsIgnoreCase(JmsHeader.JmsDeliveryMode.getName()) ) {
deliveryMode = value.toInt();
if ( deliveryMode != DeliveryMode.NON_PERSISTENT && deliveryMode != DeliveryMode.PERSISTENT)
deliveryMode = defaultDeliveryMode;
}
else if ( headerName.equalsIgnoreCase(JmsHeader.JmsPriority.getName())) {
priority = value.toInt();
if ( priority < 0 || priority > 9 )
priority = defaultPriority;
}
else if ( headerName.equalsIgnoreCase("JMSTimeToLive") ) {
timeToLive = value.toLong();
if ( timeToLive < 0 )
timeToLive = defaultTimeToLive;
}
}
else if( propName.startsWith(propertyPrefix) ) {
propName = propName.substring(propertyPrefix.length());
switch( value.getType() ) {
case DATE: msg.setLongProperty(propName, ((Date)value.getValue()).getTime()); break;
default: msg.setObjectProperty(propName, value.getValue());
}
}
}
return new SpecialJmsHeaders(deliveryMode, priority, timeToLive);