Search in sources :

Example 11 with IExtendedPipe

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

the class LockerPipeProcessor method processPipe.

@Override
protected PipeRunResult processPipe(PipeLine pipeLine, IPipe pipe, Message message, PipeLineSession pipeLineSession, ThrowingFunction<Message, PipeRunResult, PipeRunException> chain) throws PipeRunException {
    PipeRunResult pipeRunResult;
    IExtendedPipe extendedPipe = null;
    Locker locker = null;
    String objectId = null;
    if (pipe instanceof IExtendedPipe) {
        extendedPipe = (IExtendedPipe) pipe;
        locker = extendedPipe.getLocker();
    }
    if (locker != null) {
        try {
            objectId = locker.acquire();
        } catch (Exception e) {
            throw new PipeRunException(pipe, "error while trying to obtain lock [" + locker + "]", e);
        }
        if (objectId == null) {
            throw new PipeRunException(pipe, "could not obtain lock [" + locker + "]");
        }
        try {
            pipeRunResult = chain.apply(message);
        } finally {
            try {
                locker.release(objectId);
            } catch (Exception e) {
                throw new PipeRunException(pipe, "error while removing lock", e);
            }
        }
    } else {
        pipeRunResult = chain.apply(message);
    }
    return pipeRunResult;
}
Also used : PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) Locker(nl.nn.adapterframework.util.Locker) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IExtendedPipe(nl.nn.adapterframework.core.IExtendedPipe) PipeRunException(nl.nn.adapterframework.core.PipeRunException)

Aggregations

IExtendedPipe (nl.nn.adapterframework.core.IExtendedPipe)11 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)8 PipeRunException (nl.nn.adapterframework.core.PipeRunException)6 INamedObject (nl.nn.adapterframework.core.INamedObject)4 AbstractPipe (nl.nn.adapterframework.pipes.AbstractPipe)4 StatisticsKeeper (nl.nn.adapterframework.statistics.StatisticsKeeper)4 InputStream (java.io.InputStream)2 StringTokenizer (java.util.StringTokenizer)2 SAXParser (javax.xml.parsers.SAXParser)2 SAXParserFactory (javax.xml.parsers.SAXParserFactory)2 FixedForwardPipe (nl.nn.adapterframework.pipes.FixedForwardPipe)2 CompactSaxHandler (nl.nn.adapterframework.util.CompactSaxHandler)2 Locker (nl.nn.adapterframework.util.Locker)2 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Configuration (nl.nn.adapterframework.configuration.Configuration)1