Search in sources :

Example 41 with ListenerException

use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.

the class JavaListener method processRequest.

@Override
public String processRequest(String correlationId, String message, HashMap context) throws ListenerException {
    if (!isOpen()) {
        throw new ListenerException("JavaListener [" + getName() + "] is not opened");
    }
    if (log.isDebugEnabled()) {
        log.debug("JavaListener [" + getName() + "] processing correlationId [" + correlationId + "]");
    }
    if (context != null) {
        Object object = context.get("httpRequest");
        if (object != null) {
            if (object instanceof HttpServletRequest) {
                ISecurityHandler securityHandler = new HttpSecurityHandler((HttpServletRequest) object);
                context.put(IPipeLineSession.securityHandlerKey, securityHandler);
            } else {
                log.warn("No securityHandler added for httpRequest [" + object.getClass() + "]");
            }
        }
    }
    if (throwException) {
        return handler.processRequest(this, correlationId, message, context);
    } else {
        try {
            return handler.processRequest(this, correlationId, message, context);
        } catch (ListenerException e) {
            return handler.formatException(null, correlationId, message, e);
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ListenerException(nl.nn.adapterframework.core.ListenerException) ISecurityHandler(nl.nn.adapterframework.core.ISecurityHandler) HttpSecurityHandler(nl.nn.adapterframework.http.HttpSecurityHandler)

Example 42 with ListenerException

use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.

the class TestTool method jmsCleanUp.

public static boolean jmsCleanUp(String queueName, PullingJmsListener pullingJmsListener, Map writers) {
    boolean remainingMessagesFound = false;
    debugMessage("Check for remaining messages on '" + queueName + "'", writers);
    long oldTimeOut = pullingJmsListener.getTimeOut();
    pullingJmsListener.setTimeOut(10);
    boolean empty = false;
    while (!empty) {
        Object rawMessage = null;
        String message = null;
        Map threadContext = null;
        try {
            threadContext = pullingJmsListener.openThread();
            rawMessage = pullingJmsListener.getRawMessage(threadContext);
            if (rawMessage != null) {
                message = pullingJmsListener.getStringFromRawMessage(rawMessage, threadContext);
                remainingMessagesFound = true;
                if (message == null) {
                    errorMessage("Could not translate raw message from jms queue '" + queueName + "'", writers);
                } else {
                    wrongPipelineMessage("Found remaining message on '" + queueName + "'", message, writers);
                }
            }
        } catch (ListenerException e) {
            errorMessage("ListenerException on jms clean up '" + queueName + "': " + e.getMessage(), e, writers);
        } finally {
            if (threadContext != null) {
                try {
                    pullingJmsListener.closeThread(threadContext);
                } catch (ListenerException e) {
                    errorMessage("Could not close thread on jms listener '" + queueName + "': " + e.getMessage(), e, writers);
                }
            }
        }
        if (rawMessage == null) {
            empty = true;
        }
    }
    pullingJmsListener.setTimeOut((int) oldTimeOut);
    return remainingMessagesFound;
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 43 with ListenerException

use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.

the class SapListener method open.

public void open() throws ListenerException {
    try {
        openFacade();
        sapServer = new SapServer(getSapSystem(), getProgid(), this);
        sapServer.start();
        if (log.isDebugEnabled()) {
            String[][] pi = sapServer.getPropertyInfo();
            log.debug(getLogPrefix() + "properties:");
            for (int i = 0; i < pi.length; i++) {
                log.debug(getLogPrefix() + "property [" + pi[i][0] + "] (" + pi[i][1] + ") value (" + sapServer.getProperty(pi[i][0]) + ")");
            }
        }
    } catch (Exception e) {
        try {
            close();
        } catch (Exception e2) {
            log.warn("exception closing SapListener after exception opening listener", e2);
        }
        throw new ListenerException(getLogPrefix() + "could not start", e);
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ListenerException(nl.nn.adapterframework.core.ListenerException)

Example 44 with ListenerException

use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.

the class SapListener method close.

public void close() throws ListenerException {
    try {
        if (sapServer != null) {
            sapServer.stop();
            sapServer = null;
        }
    } catch (Exception e) {
        throw new ListenerException(getLogPrefix() + "could not stop", e);
    } finally {
        closeFacade();
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ListenerException(nl.nn.adapterframework.core.ListenerException)

Example 45 with ListenerException

use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.

the class PullingJmsListener method closeThread.

public void closeThread(Map threadContext) throws ListenerException {
    try {
        if (!isSessionsArePooled()) {
            MessageConsumer mc = (MessageConsumer) threadContext.remove(THREAD_CONTEXT_MESSAGECONSUMER_KEY);
            releaseReceiver(mc, null);
            Session session = (Session) threadContext.remove(THREAD_CONTEXT_SESSION_KEY);
            closeSession(session);
        }
    } catch (Exception e) {
        throw new ListenerException("exception in [" + getName() + "]", e);
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) ListenerException(nl.nn.adapterframework.core.ListenerException) JMSException(javax.jms.JMSException) TimeOutException(nl.nn.adapterframework.core.TimeOutException) ListenerException(nl.nn.adapterframework.core.ListenerException) Session(javax.jms.Session) IPipeLineSession(nl.nn.adapterframework.core.IPipeLineSession)

Aggregations

ListenerException (nl.nn.adapterframework.core.ListenerException)84 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)37 IOException (java.io.IOException)19 HashMap (java.util.HashMap)18 Map (java.util.Map)18 JMSException (javax.jms.JMSException)16 SenderException (nl.nn.adapterframework.core.SenderException)14 SQLException (java.sql.SQLException)13 PreparedStatement (java.sql.PreparedStatement)11 Session (javax.jms.Session)10 LinkedHashMap (java.util.LinkedHashMap)9 IPipeLineSession (nl.nn.adapterframework.core.IPipeLineSession)9 TimeOutException (nl.nn.adapterframework.core.TimeOutException)9 IfsaException (nl.nn.adapterframework.extensions.ifsa.IfsaException)9 Connection (java.sql.Connection)8 ResultSet (java.sql.ResultSet)8 QueueSession (javax.jms.QueueSession)8 File (java.io.File)7 MessageConsumer (javax.jms.MessageConsumer)7 Message (javax.jms.Message)6