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;
}
Aggregations