in collector/jms/src/main/java/org/apache/karaf/decanter/collector/jms/JmsCollector.java [133:178]
public void onMessage(Message message) {
if (!(message instanceof MapMessage) && !(message instanceof TextMessage)) {
LOGGER.warn("JMS is not a MapMessage or a TextMessage.");
return;
}
if (message instanceof MapMessage) {
MapMessage mapMessage = (MapMessage) message;
try {
Map<String, Object> data = new HashMap<>();
data.put("type", "jms");
Enumeration names = mapMessage.getMapNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
data.put(name, mapMessage.getObject(name));
}
PropertiesPreparator.prepare(data, properties);
Event event = new Event(dispatcherTopic, data);
dispatcher.postEvent(event);
} catch (Exception e) {
LOGGER.warn("Can't process JMS message", e);
}
}
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
Map<String, Object> data = new HashMap<>();
data.put("type", "jms");
ByteArrayInputStream is = new ByteArrayInputStream(textMessage.getText().getBytes());
data.putAll(unmarshaller.unmarshal(is));
PropertiesPreparator.prepare(data, properties);
Event event = new Event(dispatcherTopic, data);
dispatcher.postEvent(event);
} catch (Exception e) {
LOGGER.warn("Can't process JMS message", e);
}
}
}