Search in sources :

Example 6 with IMessageWrapper

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);
    }
}
Also used : IFSAHeader(com.ing.ifsa.IFSAHeader) IMessageWrapper(nl.nn.adapterframework.core.IMessageWrapper) ListenerException(nl.nn.adapterframework.core.ListenerException) JMSException(javax.jms.JMSException) IfsaException(nl.nn.adapterframework.extensions.ifsa.IfsaException) ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) JMSException(javax.jms.JMSException) TextMessage(javax.jms.TextMessage) IFSAPoisonMessage(com.ing.ifsa.IFSAPoisonMessage)

Aggregations

IMessageWrapper (nl.nn.adapterframework.core.IMessageWrapper)6 JMSException (javax.jms.JMSException)5 TextMessage (javax.jms.TextMessage)4 IFSAHeader (com.ing.ifsa.IFSAHeader)2 IFSAMessage (com.ing.ifsa.IFSAMessage)2 IFSAPoisonMessage (com.ing.ifsa.IFSAPoisonMessage)2 IFSAServiceName (com.ing.ifsa.IFSAServiceName)2 Date (java.util.Date)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Destination (javax.jms.Destination)2 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)2 ListenerException (nl.nn.adapterframework.core.ListenerException)2 IfsaException (nl.nn.adapterframework.extensions.ifsa.IfsaException)2 IFSATextMessage (com.ing.ifsa.IFSATextMessage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1