0
votes

I just started learning about the custom processor in nifi. I want to understand the specific case of working of onTrigger. I am doing some operations in onTrigger function using the property values which are defined in the nifi flow Processor interface.

Ex: Property value in the custom processor takes a string separated by ',' and in the onTrigger function I write a code which converts the string into an array of String and removes the additional white spaces.

My question is will this operation run every time a flowfile passes through the custom processor or will it be converted only once.

I tried going through the official development docs but could'nt find info on this

1
What do you mean by Compiled? Processor code compilation?daggett
@daggett Yes, I meant Process code compilation.Yoyo

1 Answers

3
votes

The Java code of a processor is compiled when you run a Maven build to produce the NAR file. The code is not compiled by NiFi itself.

You then deploy a NAR file to a NiFi instance by placing it in the lib directory, and then you use components from that NAR in your flow by adding them to the canvas.

Once a component is on the canvas and it is started, then the onTrigger method is called according to the scheduling strategy.

Whatever code is in onTrigger will run for every execution of the processor, so your code to read the property and split the value will run every time.

If the property supports expression language from flow files, then you need to run this code every time in onTrigger because the resulting value could be different for every flow file.

if the property does not support expression language from flow files, then you can instead use a method with @OnScheduled and process the property value into whatever you need, and store in a member variable of the processor, this way it only happens one time.