Search in sources :

Example 1 with IWithParameters

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

the class IbisDebuggerAdvice method debugSenderInputOutputAbort.

private <M> M debugSenderInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, Message message, PipeLineSession session, int messageParamIndex, boolean expectPipeRunResult) throws Throwable {
    if (!isEnabled()) {
        return (M) proceedingJoinPoint.proceed();
    }
    ISender sender = (ISender) proceedingJoinPoint.getTarget();
    if (!sender.isSynchronous() && sender instanceof JmsSender) {
        // Ignore JmsSenders within JmsListeners (calling JmsSender without ParameterResolutionContext) within Receivers.
        return (M) proceedingJoinPoint.proceed();
    }
    String messageId = session == null ? null : session.getMessageId();
    message = ibisDebugger.senderInput(sender, messageId, message);
    // result can be PipeRunResult (for StreamingSenders) or Message (for all other Senders)
    M result = null;
    // debugSenderGetInputFrom will be called.
    if (!ibisDebugger.stubSender(sender, messageId) || sender instanceof SenderWrapperBase) {
        try {
            Object[] args = proceedingJoinPoint.getArgs();
            args[messageParamIndex] = message;
            result = (M) proceedingJoinPoint.proceed(args);
        } catch (Throwable throwable) {
            throw ibisDebugger.senderAbort(sender, messageId, throwable);
        }
    } else {
        // resolve parameters itself
        if (sender instanceof IWithParameters) {
            ParameterList parameterList = ((IWithParameters) sender).getParameterList();
            if (parameterList != null) {
                parameterList.getValues(message, session);
            }
        }
    }
    if (sender instanceof SenderWrapperBase && ((SenderWrapperBase) sender).isPreserveInput()) {
        // signal in the debugger that the result of the sender has been replaced with the original input
        result = (M) ibisDebugger.preserveInput(messageId, (Message) result);
    }
    if (expectPipeRunResult) {
        // Create PipeRunResult when streaming sender is stubbed, this will forward to the next pipe and process the
        // message in a streaming.auto=false way (also when at the time of the original report the message was
        // processed with streaming.auto=true)
        PipeRunResult prr = result != null ? (PipeRunResult) result : new PipeRunResult();
        prr.setResult(ibisDebugger.senderOutput(sender, messageId, prr.getResult()));
        return (M) prr;
    }
    return (M) ibisDebugger.senderOutput(sender, messageId, Message.asMessage(result));
}
Also used : SenderWrapperBase(nl.nn.adapterframework.senders.SenderWrapperBase) PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) ISender(nl.nn.adapterframework.core.ISender) IWithParameters(nl.nn.adapterframework.core.IWithParameters) ParameterList(nl.nn.adapterframework.parameters.ParameterList) INamedObject(nl.nn.adapterframework.core.INamedObject) JmsSender(nl.nn.adapterframework.jms.JmsSender)

Aggregations

INamedObject (nl.nn.adapterframework.core.INamedObject)1 ISender (nl.nn.adapterframework.core.ISender)1 IWithParameters (nl.nn.adapterframework.core.IWithParameters)1 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)1 JmsSender (nl.nn.adapterframework.jms.JmsSender)1 ParameterList (nl.nn.adapterframework.parameters.ParameterList)1 SenderWrapperBase (nl.nn.adapterframework.senders.SenderWrapperBase)1