Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

how to add java main class code to custom processor ?

avatar
Explorer

Hi Folks,

I have written one custom java code. i want make that as custom processor.

My code has total 4 classes.

Client.java

SFTPFile.java

JobRunner.java

ExcelJob.java

Client.java class has Main function and it expects input file. as of now we have given hard coded value. like below

this job will run continuously once we start mail class. can you help me, how to add this java code to custom processor.

My custom processor will need to accept one input property. it will allow us to give input CSV file path.. Once we run that processor, it will take the input csv file and trigger the Client main class. Main class will run continuously. Code written like that.

in Below code, we hard coded csv file path. we want to make that as property allow to give path in processor.

-------------

public class Client { public static void main(String[] args) throws SchedulerException {

JobRunner job = new JobRunner("D:\\nifi_test\\java_test_nifi_csv_file.csv");

job.run();

}

-------------------------rest classes, we used inner.

I just created one custom processor as per

https://community.hortonworks.com/articles/4318/build-custom-nifi-processor.html

but confused, how to copy my code to custom processor. Can you please help me on this.

i am attaching my code for reference.

Please use attached code and share nar file if possible.sftp.zip

Thanks,
Rangareddy Y

1 ACCEPTED SOLUTION

avatar
Explorer
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
4 REPLIES 4

avatar
Explorer

use onTrigger method to write your code whichever there in main method, and instead of passing full path address pass from that constructor input stream of that file. Give me one day I will come with nar file of that custom processor

avatar
Explorer
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Explorer

Thanks for the reply @Gourav Bhattacharya. Now i started the custom processor. Once jobRunner class starts, it will run continuously. i am not able to stop the process. even i stop custom process, it is not stopping the jobRunner. there is no link between custom processor stop and JobRunner class stop. Please suggest me how to implement stop mechanism in custom processor. if i stop custom processor, it shold stop jobRunner also.

Thanks,

Rangareddy Y

avatar
Explorer

can you send me the job runner code exact line with comment