Created 11-10-2016 12:47 PM
I am new to the Nifi and I am searching out something like calling one process group from another process group when its success.
Ex: suppose I am having one process group/Process like ExecuteScript (Schedule to run daily once) which will execute some script once its success it will dynamically start another process group. else its send mail with some message.
It will be helpful if I get any example or reference how I can achieve this.
Thanks in advance.....
Created on 11-10-2016 01:13 PM - edited 08-18-2019 03:36 AM
Your requirement is basically how NiFi works. When making a connection between two processors, you are asked (for processors where this is relevant) to make a SUCCESS or FAILURE connection. Thus, from one processor make a success connection to the downstream processor to be triggered on success and then make a separate failure connection to the one to respond to failures (in your case, PutEmail processor).
This works the same for connections between processors as it does for connection between process groups.
Specifically for ExecuteScript, in the script you define success and failure as follows:
session.transfer(flowFile, REL_SUCCESS) // or session.transfer(flowFile, REL_FAILURE)
For links to getting started with NiFi, see:
For ExecuteScript specifically, see: http://funnifi.blogspot.com/2016/02/executescript-processor-hello-world.html
Created on 11-10-2016 01:13 PM - edited 08-18-2019 03:36 AM
Your requirement is basically how NiFi works. When making a connection between two processors, you are asked (for processors where this is relevant) to make a SUCCESS or FAILURE connection. Thus, from one processor make a success connection to the downstream processor to be triggered on success and then make a separate failure connection to the one to respond to failures (in your case, PutEmail processor).
This works the same for connections between processors as it does for connection between process groups.
Specifically for ExecuteScript, in the script you define success and failure as follows:
session.transfer(flowFile, REL_SUCCESS) // or session.transfer(flowFile, REL_FAILURE)
For links to getting started with NiFi, see:
For ExecuteScript specifically, see: http://funnifi.blogspot.com/2016/02/executescript-processor-hello-world.html
Created 11-10-2016 04:21 PM
Thanks for the replay, and i will try to do this.
But my requirement is different - Let take I have one Execute script which is crontag to run daily once and under this script i will search for 1 file which will load every month, so suppose today my crontab will run the execute script and it not find the file, so as file is not there the other process - "Load file in HDFS" will not call/start/run , and in next day when cron tag again run the execute script it will find the file then the other process should start/run but my previous step or do we have any other alternative to start my "Load file in HDFS" automatically when files are presented.
Created 11-10-2016 06:34 PM
@Gurpreet Singh If I am understanding the requirement correctly, you should define REL_SUCCESS in the script if you find the file, and this is connected to the processor you want to kick off. Define REL_FAILURE if the file is not found, and kickoff the processor you want for that fail condition.
For python example, see:
https://community.hortonworks.com/articles/35568/python-script-in-nifi.html https://gist.github.com/mattyb149/89205fcbc6d0e15ba024
Note the line: session.transfer(flowFile, REL_SUCCESS)
Created 11-11-2016 05:15 PM
Thanks Greg, Yes it correct , but in ExecuteScript I am using Python so can I use REL_SUCCESS, can you share some example of using REL_SUCCESS in python
Created 11-11-2016 05:50 PM
@Gurpreet Singh I updated the previous answer with links to ExecuteScript using python scripts, and the important line: session.transfer(flowFile, REL_SUCCESS)
Created 12-16-2016 09:12 PM
@Greg Keys has provided the link you requested (ref REL_SUCCESS): http://funnifi.blogspot.com/2016/02/executescript-processor-hello-world.html