Search in sources :

Example 81 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();
        log.debug(getLogPrefix() + "register ServerDataProvider");
        Environment.registerServerDataProvider(this);
        serverDataEventListener.updated(getName());
        log.debug(getLogPrefix() + "start server");
        JCoIDocServer server = JCoIDoc.getServer(getName());
        server.setCallHandlerFactory(functionHandlerFactory);
        server.setIDocHandlerFactory(this);
        server.setTIDHandler(this);
        server.addServerErrorListener(this);
        server.addServerExceptionListener(this);
        server.start();
    } 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 : JCoIDocServer(com.sap.conn.idoc.jco.JCoIDocServer) ListenerException(nl.nn.adapterframework.core.ListenerException) JCoRuntimeException(com.sap.conn.jco.JCoRuntimeException) ListenerException(nl.nn.adapterframework.core.ListenerException) JCoException(com.sap.conn.jco.JCoException) AbapClassException(com.sap.conn.jco.AbapClassException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) AbapException(com.sap.conn.jco.AbapException)

Example 82 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 {
        log.debug(getLogPrefix() + "stop server");
        JCoServer server = JCoServerFactory.getServer(getName());
        server.stop();
        log.debug(getLogPrefix() + "unregister ServerDataProvider");
    // Delete doesn't work after stopping the server, when calling
    // delete first the stop method will fail.
    // serverDataEventListener.deleted(getName());
    } catch (Exception e) {
        throw new ListenerException(getLogPrefix() + "could not stop", e);
    } finally {
        try {
            Environment.unregisterServerDataProvider(this);
        } catch (Exception e) {
            throw new ListenerException(getLogPrefix() + "could not unregister", e);
        } finally {
            closeFacade();
        }
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) JCoServer(com.sap.conn.jco.server.JCoServer) JCoRuntimeException(com.sap.conn.jco.JCoRuntimeException) ListenerException(nl.nn.adapterframework.core.ListenerException) JCoException(com.sap.conn.jco.JCoException) AbapClassException(com.sap.conn.jco.AbapClassException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) AbapException(com.sap.conn.jco.AbapException)

Example 83 with ListenerException

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

the class SapListener method afterMessageProcessed.

public void afterMessageProcessed(PipeLineResult processResult, Object rawMessage, Map threadContext) throws ListenerException {
    try {
        log.debug("SapListener.afterMessageProcessed");
        message2FunctionResult((JCO.Function) rawMessage, processResult.getResult());
    } catch (SapException e) {
        throw new ListenerException(e);
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) JCO(com.sap.mw.jco.JCO)

Example 84 with ListenerException

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

the class IbisLocalSender method sendMessage.

public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
    String result = null;
    HashMap context = null;
    if (paramList != null) {
        try {
            context = (HashMap) prc.getValueMap(paramList);
        } catch (ParameterException e) {
            throw new SenderException(getLogPrefix() + "exception evaluating parameters", e);
        }
    } else {
        if (StringUtils.isNotEmpty(getReturnedSessionKeys())) {
            context = new HashMap();
        }
    }
    if (StringUtils.isNotEmpty(getServiceName())) {
        try {
            if (isIsolated()) {
                if (isSynchronous()) {
                    log.debug(getLogPrefix() + "calling service [" + getServiceName() + "] in separate Thread");
                    result = isolatedServiceCaller.callServiceIsolated(getServiceName(), correlationID, message, context, false);
                } else {
                    log.debug(getLogPrefix() + "calling service [" + getServiceName() + "] in asynchronously");
                    isolatedServiceCaller.callServiceAsynchronous(getServiceName(), correlationID, message, context, false);
                    result = message;
                }
            } else {
                log.debug(getLogPrefix() + "calling service [" + getServiceName() + "] in same Thread");
                result = ServiceDispatcher.getInstance().dispatchRequest(getServiceName(), correlationID, message, context);
            }
        } catch (ListenerException e) {
            if (ExceptionUtils.getRootCause(e) instanceof TimeOutException) {
                throw new TimeOutException(getLogPrefix() + "timeout calling service [" + getServiceName() + "]", e);
            } else {
                throw new SenderException(getLogPrefix() + "exception calling service [" + getServiceName() + "]", e);
            }
        } finally {
            if (log.isDebugEnabled() && StringUtils.isNotEmpty(getReturnedSessionKeys())) {
                log.debug("returning values of session keys [" + getReturnedSessionKeys() + "]");
            }
            if (prc != null) {
                Misc.copyContext(getReturnedSessionKeys(), context, prc.getSession());
            }
        }
    } else {
        String javaListener;
        if (StringUtils.isNotEmpty(getJavaListenerSessionKey())) {
            javaListener = (String) prc.getSession().get(getJavaListenerSessionKey());
        } else {
            javaListener = getJavaListener();
        }
        try {
            JavaListener listener = JavaListener.getListener(javaListener);
            if (listener == null) {
                String msg = "could not find JavaListener [" + javaListener + "]";
                if (isThrowJavaListenerNotFoundException()) {
                    throw new SenderException(msg);
                } else {
                    log.info(getLogPrefix() + msg);
                    return "<error>" + msg + "</error>";
                }
            }
            if (isIsolated()) {
                if (isSynchronous()) {
                    log.debug(getLogPrefix() + "calling JavaListener [" + javaListener + "] in separate Thread");
                    result = isolatedServiceCaller.callServiceIsolated(javaListener, correlationID, message, context, true);
                } else {
                    log.debug(getLogPrefix() + "calling JavaListener [" + javaListener + "] in asynchronously");
                    isolatedServiceCaller.callServiceAsynchronous(javaListener, correlationID, message, context, true);
                    result = message;
                }
            } else {
                log.debug(getLogPrefix() + "calling JavaListener [" + javaListener + "] in same Thread");
                result = listener.processRequest(correlationID, message, context);
            }
        } catch (ListenerException e) {
            if (ExceptionUtils.getRootCause(e) instanceof TimeOutException) {
                throw new TimeOutException(getLogPrefix() + "timeout calling JavaListener [" + javaListener + "]", e);
            } else {
                throw new SenderException(getLogPrefix() + "exception calling JavaListener [" + javaListener + "]", e);
            }
        } finally {
            if (log.isDebugEnabled() && StringUtils.isNotEmpty(getReturnedSessionKeys())) {
                log.debug("returning values of session keys [" + getReturnedSessionKeys() + "]");
            }
            if (prc != null) {
                Misc.copyContext(getReturnedSessionKeys(), context, prc.getSession());
            }
        }
    }
    return result;
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) TimeOutException(nl.nn.adapterframework.core.TimeOutException) HashMap(java.util.HashMap) JavaListener(nl.nn.adapterframework.receivers.JavaListener) ParameterException(nl.nn.adapterframework.core.ParameterException) SenderException(nl.nn.adapterframework.core.SenderException)

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