6
Özellikleri bir JMS iletisinden diğerine kopyalamanın kolay bir yolu var mı?Kopya JMS İleti özellikleri
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;
...
}
}
}
Ama bu ciddi çirkin:
böyle bir şey tahmin edebilirsiniz. başka bir yol Burada
A LinkedHashMap düzeni korumak için daha iyidir var – mcoolive