use of nl.nn.adapterframework.core.IMessageWrapper in project iaf by ibissource.
the class PushingIfsaProviderListener method getStringFromRawMessage.
/**
* Extracts string from message obtained from {@link #getRawMessage(Map)}. May also extract
* other parameters from the message and put those in the threadContext.
* @return input message for adapter.
*/
public String getStringFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
if (rawMessage instanceof IMessageWrapper) {
return getStringFromWrapper((IMessageWrapper) rawMessage, threadContext);
}
if (rawMessage instanceof IFSAPoisonMessage) {
IFSAPoisonMessage pm = (IFSAPoisonMessage) rawMessage;
IFSAHeader header = pm.getIFSAHeader();
String source;
try {
source = header.getIFSA_Source();
} catch (Exception e) {
source = "unknown due to exeption:" + e.getMessage();
}
return "<poisonmessage>" + " <source>" + source + "</source>" + " <contents>" + XmlUtils.encodeChars(ToStringBuilder.reflectionToString(pm)) + "</contents>" + "</poisonmessage>";
}
TextMessage message = null;
try {
message = (TextMessage) rawMessage;
} catch (ClassCastException e) {
log.warn(getLogPrefix() + "message received was not of type TextMessage, but [" + rawMessage.getClass().getName() + "]", e);
return null;
}
try {
String result = message.getText();
threadContext.put(THREAD_CONTEXT_ORIGINAL_RAW_MESSAGE_KEY, message);
return result;
} catch (JMSException e) {
throw new ListenerException(getLogPrefix(), e);
}
}
Aggregations