Search in sources :

Example 1 with DispatcherManager

use of nl.nn.adapterframework.dispatcher.DispatcherManager in project iaf by ibissource.

the class IbisJavaSender method sendMessage.

public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
    String result = null;
    HashMap context = null;
    try {
        if (paramList != null) {
            context = (HashMap) prc.getValueMap(paramList);
        } else {
            context = new HashMap();
        }
        DispatcherManager dm = null;
        Class c = Class.forName("nl.nn.adapterframework.dispatcher.DispatcherManagerFactory");
        if (getDispatchType().equalsIgnoreCase("DLL")) {
            String version = nl.nn.adapterframework.dispatcher.Version.version;
            if (version.contains("IbisServiceDispatcher 1.3"))
                throw new SenderException("IBIS-ServiceDispatcher out of date! Please update to version 1.4 or higher");
            Method getDispatcherManager = c.getMethod("getDispatcherManager", String.class);
            dm = (DispatcherManager) getDispatcherManager.invoke(null, getDispatchType());
        } else {
            Method getDispatcherManager = c.getMethod("getDispatcherManager");
            dm = (DispatcherManager) getDispatcherManager.invoke(null, (Object[]) null);
        }
        result = dm.processRequest(getServiceName(), correlationID, message, context);
        if (isMultipartResponse()) {
            return HttpSender.handleMultipartResponse(multipartResponseContentType, new ByteArrayInputStream(result.getBytes(multipartResponseCharset)), prc, null);
        }
    } catch (ParameterException e) {
        throw new SenderException(getLogPrefix() + "exception evaluating parameters", e);
    } catch (Exception e) {
        throw new SenderException(getLogPrefix() + "exception processing message using request processor [" + 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());
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) DispatcherManager(nl.nn.adapterframework.dispatcher.DispatcherManager) ParameterException(nl.nn.adapterframework.core.ParameterException) Method(java.lang.reflect.Method) SenderException(nl.nn.adapterframework.core.SenderException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) TimeOutException(nl.nn.adapterframework.core.TimeOutException) SenderException(nl.nn.adapterframework.core.SenderException) ParameterException(nl.nn.adapterframework.core.ParameterException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 ParameterException (nl.nn.adapterframework.core.ParameterException)1 SenderException (nl.nn.adapterframework.core.SenderException)1 TimeOutException (nl.nn.adapterframework.core.TimeOutException)1 DispatcherManager (nl.nn.adapterframework.dispatcher.DispatcherManager)1