Support Questions
Find answers, ask questions, and share your expertise

Calling Process Dynamic

Explorer

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.....

1 ACCEPTED SOLUTION

Accepted Solutions

Guru

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).

9304-screen-shot-2016-11-10-at-82427-am.png

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

View solution in original post

6 REPLIES 6

Guru

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).

9304-screen-shot-2016-11-10-at-82427-am.png

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

View solution in original post

Explorer

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.

Guru

@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)

Explorer

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

Guru

@Gurpreet Singh I updated the previous answer with links to ExecuteScript using python scripts, and the important line: session.transfer(flowFile, REL_SUCCESS)