Here's the solution I ended up with ...
@SuppressWarnings("unchecked") private static HashMap<String, Object> getMessageProperties(Message msg) throws JMSException { HashMap<String, Object> properties = new HashMap<String, Object> (); Enumeration srcProperties = msg.getPropertyNames(); while (srcProperties.hasMoreElements()) { String propertyName = (String)srcProperties.nextElement (); properties.put(propertyName, msg.getObjectProperty (propertyName)); } return properties; } private static void setMessageProperties(Message msg, HashMap<String, Object> properties) throws JMSException { if (properties == null) { return; } for (Map.Entry<String, Object> entry : properties.entrySet()) { String propertyName = entry.getKey (); Object value = entry.getValue (); msg.setObjectProperty(propertyName, value); } }
Shaun
source share