Is it possible to send flowfile on @OnStopped annotation?
Basically, I want to write custom processor which can send an attribute in flowFile on the stop of processor.
Any suggestions?
I was trying below :
ProcessSession session;
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
if (flowFile == null) {
flowFile = session.create();
}
flowFile = session.putAttribute(flowFile, "ATTRIBUTE_SIGNAL", "start");
session.transfer(flowFile, success);
}
@OnStopped
public void sendStop() {
FlowFile flowFile = session.get();
flowFile = session.create();
flowFile = session.putAttribute(flowFile, "ATTRIBUTE_SIGNAL", "stop");
session.transfer(flowFile, success);
}
but it is failing with
2018-04-30 20:44:25,540 ERROR [StandardProcessScheduler Thread-3] org.apache.nifi.util.ReflectionUtils Failed while invoking annotated method 'public void com.kotak.nifi.processors.streaming.SignalGenerator.sendStop()' with arguments '[]'.
java.lang.reflect.InvocationTargetException: null.