Search in sources :

Example 1 with EsbSoapWrapperPipe

use of nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe in project iaf by ibissource.

the class MessageSendingPipe method configure.

/**
 * Checks whether a sender is defined for this pipe.
 */
@Override
public void configure() throws ConfigurationException {
    super.configure();
    if (StringUtils.isNotEmpty(getStubFileName())) {
        URL stubUrl;
        try {
            stubUrl = ClassUtils.getResourceURL(classLoader, getStubFileName());
        } catch (Throwable e) {
            throw new ConfigurationException(getLogPrefix(null) + "got exception finding resource for stubfile [" + getStubFileName() + "]", e);
        }
        if (stubUrl == null) {
            throw new ConfigurationException(getLogPrefix(null) + "could not find resource for stubfile [" + getStubFileName() + "]");
        }
        try {
            returnString = Misc.resourceToString(stubUrl, SystemUtils.LINE_SEPARATOR);
        } catch (Throwable e) {
            throw new ConfigurationException(getLogPrefix(null) + "got exception loading stubfile [" + getStubFileName() + "] from resource [" + stubUrl.toExternalForm() + "]", e);
        }
    } else {
        propagateName();
        if (getSender() == null) {
            throw new ConfigurationException(getLogPrefix(null) + "no sender defined ");
        }
        try {
            if (getSender() instanceof PipeAware) {
                ((PipeAware) getSender()).setPipe(this);
            }
            getSender().configure();
        } catch (ConfigurationException e) {
            throw new ConfigurationException(getLogPrefix(null) + "while configuring sender", e);
        }
        if (getSender() instanceof HasPhysicalDestination) {
            log.info(getLogPrefix(null) + "has sender on " + ((HasPhysicalDestination) getSender()).getPhysicalDestinationName());
        }
        if (getListener() != null) {
            if (getSender().isSynchronous()) {
                throw new ConfigurationException(getLogPrefix(null) + "cannot have listener with synchronous sender");
            }
            try {
                getListener().configure();
            } catch (ConfigurationException e) {
                throw new ConfigurationException(getLogPrefix(null) + "while configuring listener", e);
            }
            if (getListener() instanceof HasPhysicalDestination) {
                log.info(getLogPrefix(null) + "has listener on " + ((HasPhysicalDestination) getListener()).getPhysicalDestinationName());
            }
        }
        if (!(getLinkMethod().equalsIgnoreCase("MESSAGEID")) && (!(getLinkMethod().equalsIgnoreCase("CORRELATIONID")))) {
            throw new ConfigurationException(getLogPrefix(null) + "Invalid argument for property LinkMethod [" + getLinkMethod() + "]. it should be either MESSAGEID or CORRELATIONID");
        }
        if (!(getHideMethod().equalsIgnoreCase("all")) && (!(getHideMethod().equalsIgnoreCase("firstHalf")))) {
            throw new ConfigurationException(getLogPrefix(null) + "invalid value for hideMethod [" + getHideMethod() + "], must be 'all' or 'firstHalf'");
        }
        if (isCheckXmlWellFormed() || StringUtils.isNotEmpty(getCheckRootTag())) {
            if (findForward(ILLEGAL_RESULT_FORWARD) == null)
                throw new ConfigurationException(getLogPrefix(null) + "has no forward with name [illegalResult]");
        }
        if (!ConfigurationUtils.stubConfiguration()) {
            if (StringUtils.isNotEmpty(getTimeOutOnResult())) {
                throw new ConfigurationException(getLogPrefix(null) + "timeOutOnResult only allowed in stub mode");
            }
            if (StringUtils.isNotEmpty(getExceptionOnResult())) {
                throw new ConfigurationException(getLogPrefix(null) + "exceptionOnResult only allowed in stub mode");
            }
        }
        if (getMaxRetries() > 0) {
            ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
            if (getRetryMinInterval() < MIN_RETRY_INTERVAL) {
                String msg = "retryMinInterval [" + getRetryMinInterval() + "] should be greater than or equal to [" + MIN_RETRY_INTERVAL + "], assuming the lower limit";
                configWarnings.add(log, msg);
                setRetryMinInterval(MIN_RETRY_INTERVAL);
            }
            if (getRetryMaxInterval() > MAX_RETRY_INTERVAL) {
                String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be less than or equal to [" + MAX_RETRY_INTERVAL + "], assuming the upper limit";
                configWarnings.add(log, msg);
                setRetryMaxInterval(MAX_RETRY_INTERVAL);
            }
            if (getRetryMaxInterval() < getRetryMinInterval()) {
                String msg = "retryMaxInterval [" + getRetryMaxInterval() + "] should be greater than or equal to [" + getRetryMinInterval() + "], assuming the lower limit";
                configWarnings.add(log, msg);
                setRetryMaxInterval(getRetryMinInterval());
            }
        }
    }
    ITransactionalStorage messageLog = getMessageLog();
    if (checkMessageLog) {
        if (!getSender().isSynchronous() && getListener() == null && !(getSender() instanceof nl.nn.adapterframework.senders.IbisLocalSender)) {
            if (messageLog == null) {
                ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                String msg = "asynchronous sender [" + getSender().getName() + "] without sibling listener has no messageLog. Integrity check not possible";
                configWarnings.add(log, msg);
            }
        }
    }
    if (messageLog != null) {
        messageLog.configure();
        if (messageLog instanceof HasPhysicalDestination) {
            String msg = getLogPrefix(null) + "has messageLog in " + ((HasPhysicalDestination) messageLog).getPhysicalDestinationName();
            log.info(msg);
            if (getAdapter() != null)
                getAdapter().getMessageKeeper().add(msg);
        }
        if (StringUtils.isNotEmpty(getAuditTrailXPath())) {
            auditTrailTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getAuditTrailNamespaceDefs(), getAuditTrailXPath(), null, "text", false, null);
        }
        if (StringUtils.isNotEmpty(getCorrelationIDXPath()) || StringUtils.isNotEmpty(getCorrelationIDStyleSheet())) {
            correlationIDTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getCorrelationIDNamespaceDefs(), getCorrelationIDXPath(), getCorrelationIDStyleSheet(), "text", false, null);
        }
        if (StringUtils.isNotEmpty(getLabelXPath()) || StringUtils.isNotEmpty(getLabelStyleSheet())) {
            labelTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getLabelNamespaceDefs(), getLabelXPath(), getLabelStyleSheet(), "text", false, null);
        }
    }
    if (StringUtils.isNotEmpty(getRetryXPath())) {
        retryTp = TransformerPool.configureTransformer(getLogPrefix(null), classLoader, getRetryNamespaceDefs(), getRetryXPath(), null, "text", false, null);
    }
    IPipe inputValidator = getInputValidator();
    IPipe outputValidator = getOutputValidator();
    if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
        outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
        setOutputValidator(outputValidator);
    }
    if (inputValidator != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        inputValidator.registerForward(pf);
    // inputValidator.configure(); // configure is handled in PipeLine.configure()
    }
    if (outputValidator != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        outputValidator.registerForward(pf);
    // outputValidator.configure(); // configure is handled in PipeLine.configure()
    }
    if (getInputWrapper() != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        getInputWrapper().registerForward(pf);
        if (getInputWrapper() instanceof EsbSoapWrapperPipe) {
            EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getInputWrapper();
            ISender sender = getSender();
            eswPipe.retrievePhysicalDestinationFromSender(sender);
        }
    }
    if (getOutputWrapper() != null) {
        PipeForward pf = new PipeForward();
        pf.setName(SUCCESS_FORWARD);
        getOutputWrapper().registerForward(pf);
    }
    registerEvent(PIPE_TIMEOUT_MONITOR_EVENT);
    registerEvent(PIPE_CLEAR_TIMEOUT_MONITOR_EVENT);
    registerEvent(PIPE_EXCEPTION_MONITOR_EVENT);
}
Also used : ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) EsbSoapWrapperPipe(nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe) IDualModeValidator(nl.nn.adapterframework.core.IDualModeValidator) PipeForward(nl.nn.adapterframework.core.PipeForward) URL(java.net.URL) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ISender(nl.nn.adapterframework.core.ISender) IPipe(nl.nn.adapterframework.core.IPipe) HasPhysicalDestination(nl.nn.adapterframework.core.HasPhysicalDestination)

Example 2 with EsbSoapWrapperPipe

use of nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe in project iaf by ibissource.

the class PipeLine method configure.

/**
 * Configures the pipes of this Pipeline and does some basic checks. It also
 * registers the <code>PipeLineSession</code> object at the pipes.
 * @see IPipe
 */
public void configure() throws ConfigurationException {
    INamedObject owner = getOwner();
    IAdapter adapter = null;
    if (owner instanceof IAdapter) {
        adapter = (IAdapter) owner;
    }
    if (cache != null) {
        cache.configure(owner.getName() + "-Pipeline");
    }
    for (int i = 0; i < pipes.size(); i++) {
        IPipe pipe = getPipe(i);
        log.debug("Pipeline of [" + owner.getName() + "] configuring Pipe [" + pipe.getName() + "]");
        // forward is defined, it is not overwritten by the globals
        for (String gfName : globalForwards.keySet()) {
            PipeForward pipeForward = globalForwards.get(gfName);
            pipe.registerForward(pipeForward);
        }
        if (pipe instanceof FixedForwardPipe) {
            FixedForwardPipe ffpipe = (FixedForwardPipe) pipe;
            if (ffpipe.findForward("success") == null) {
                int i2 = i + 1;
                if (i2 < pipes.size()) {
                    String nextPipeName = getPipe(i2).getName();
                    PipeForward pf = new PipeForward();
                    pf.setName("success");
                    pf.setPath(nextPipeName);
                    pipe.registerForward(pf);
                } else {
                    PipeLineExit plexit = findExitByState("success");
                    if (plexit != null) {
                        PipeForward pf = new PipeForward();
                        pf.setName("success");
                        pf.setPath(plexit.getPath());
                        pipe.registerForward(pf);
                    }
                }
            }
        }
        configure(pipe);
    }
    if (pipeLineExits.size() < 1) {
        throw new ConfigurationException("no PipeLine Exits specified");
    }
    if (this.firstPipe == null) {
        throw new ConfigurationException("no firstPipe defined");
    }
    if (getPipe(firstPipe) == null) {
        throw new ConfigurationException("no pipe found for firstPipe [" + firstPipe + "]");
    }
    IPipe inputValidator = getInputValidator();
    IPipe outputValidator = getOutputValidator();
    if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
        outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
        setOutputValidator(outputValidator);
    }
    if (inputValidator != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring InputValidator");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        inputValidator.registerForward(pf);
        inputValidator.setName(INPUT_VALIDATOR_NAME);
        configure(inputValidator);
    }
    if (outputValidator != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring OutputValidator");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        outputValidator.registerForward(pf);
        outputValidator.setName(OUTPUT_VALIDATOR_NAME);
        configure(outputValidator);
    }
    if (getInputWrapper() != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring InputWrapper");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        getInputWrapper().registerForward(pf);
        getInputWrapper().setName(INPUT_WRAPPER_NAME);
        configure(getInputWrapper());
    }
    if (getOutputWrapper() != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring OutputWrapper");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        if (getOutputWrapper() instanceof AbstractPipe && adapter instanceof Adapter) {
            ((AbstractPipe) getOutputWrapper()).setRecoverAdapter(((Adapter) adapter).isRecover());
        }
        getOutputWrapper().registerForward(pf);
        getOutputWrapper().setName(OUTPUT_WRAPPER_NAME);
        if (getOutputWrapper() instanceof EsbSoapWrapperPipe) {
            EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getOutputWrapper();
            boolean stop = false;
            Iterator<IReceiver> recIt = adapter.getReceiverIterator();
            if (recIt.hasNext()) {
                while (recIt.hasNext() && !stop) {
                    IReceiver receiver = recIt.next();
                    if (receiver instanceof ReceiverBase) {
                        ReceiverBase rb = (ReceiverBase) receiver;
                        IListener listener = rb.getListener();
                        try {
                            if (eswPipe.retrievePhysicalDestinationFromListener(listener)) {
                                stop = true;
                            }
                        } catch (JmsException e) {
                            throw new ConfigurationException(e);
                        }
                    }
                }
            }
        }
        configure(getOutputWrapper());
    }
    requestSizeStats = new SizeStatisticsKeeper("- pipeline in");
    if (isTransacted() && getTransactionTimeout() > 0) {
        String systemTransactionTimeout = Misc.getSystemTransactionTimeout();
        if (systemTransactionTimeout != null && StringUtils.isNumeric(systemTransactionTimeout)) {
            int stt = Integer.parseInt(systemTransactionTimeout);
            if (getTransactionTimeout() > stt) {
                ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                String msg = "Pipeline of [" + owner.getName() + "] has a transaction timeout [" + getTransactionTimeout() + "] which exceeds the system transaction timeout [" + stt + "]";
                configWarnings.add(log, msg);
            }
        }
    }
    int txOption = this.getTransactionAttributeNum();
    if (log.isDebugEnabled())
        log.debug("creating TransactionDefinition for transactionAttribute [" + getTransactionAttribute() + "], timeout [" + getTransactionTimeout() + "]");
    txDef = SpringTxManagerProxy.getTransactionDefinition(txOption, getTransactionTimeout());
    log.debug("Pipeline of [" + owner.getName() + "] successfully configured");
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) EsbSoapWrapperPipe(nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe) ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) JmsException(nl.nn.adapterframework.jms.JmsException) SizeStatisticsKeeper(nl.nn.adapterframework.statistics.SizeStatisticsKeeper) ICacheAdapter(nl.nn.adapterframework.cache.ICacheAdapter) AbstractPipe(nl.nn.adapterframework.pipes.AbstractPipe) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) FixedForwardPipe(nl.nn.adapterframework.pipes.FixedForwardPipe)

Aggregations

ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)2 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)2 EsbSoapWrapperPipe (nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe)2 URL (java.net.URL)1 ICacheAdapter (nl.nn.adapterframework.cache.ICacheAdapter)1 HasPhysicalDestination (nl.nn.adapterframework.core.HasPhysicalDestination)1 IDualModeValidator (nl.nn.adapterframework.core.IDualModeValidator)1 IPipe (nl.nn.adapterframework.core.IPipe)1 ISender (nl.nn.adapterframework.core.ISender)1 ITransactionalStorage (nl.nn.adapterframework.core.ITransactionalStorage)1 PipeForward (nl.nn.adapterframework.core.PipeForward)1 JmsException (nl.nn.adapterframework.jms.JmsException)1 AbstractPipe (nl.nn.adapterframework.pipes.AbstractPipe)1 FixedForwardPipe (nl.nn.adapterframework.pipes.FixedForwardPipe)1 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)1 SizeStatisticsKeeper (nl.nn.adapterframework.statistics.SizeStatisticsKeeper)1