Is there an easy way of copying off the properties from one JMS message to another?
I can imagine something like this:
private void copyMessageProperties (Message msg1, Message msg2) throws JMSException {
Enumeration srcProperties = msg1.getPropertyNames();
while (srcProperties.hasMoreElements()) {
String propertyName = (String) srcProperties.nextElement ();
// Now try to read and set
try {
Object obj = msg1.getObjectProperty (propertyName);
msg2.setObjectProperty (propertyName, obj);
continue;
} catch (Exception e) {}
try {
String str = msg1.getStringProperty (propertyName);
msg2.setStringProperty (propertyName, str);
continue;
...
}
}
But that is seriously ugly. There must be another way