Support Questions

Find answers, ask questions, and share your expertise

How to Set ProcessContext for Nifi from a java class?

New Contributor

I want to write my own code which will run Nifi processor from a java class ,how I can create set ProcessContext value and pass to onTrigger method ?

I didn’t find any settermethod for ProcessContext class methods .


Super Guru

The ProcessContext is set by the framework and passed to onTrigger(). What kinds of values are you trying to pass? Usually the ProcessContext is used to get the values of your processor's properties.

New Contributor

I want to use Nifi without UI .

As using UI we can set all the property value in UI and same will be passed to onTrigger with all the values in ProcessContext.

How I can assign the value to Property without UI and pass to onTrigger using ProcessContext.

Like all the value we can provide to ExecuteSQLRecord processor in UI which will be set to ProcessContext,how same can be achieved without UI.

Super Guru

The UI just makes REST API calls to NiFi to set things like processor properties. You'd have to make the REST call(s) yourself to set the values for the processor properties, then when you start the processor, onTrigger() will have a ProcessContext that has your settings for those properties' values. Check the REST API documentation for more information, and you can also enable Developer Tools on your browser while setting properties with the UI, after hitting the Apply button you can see the POST call(s) being made, and you can use those as guidance for how to do it without the UI.

New Contributor

you are correct all the UI component calls REST API however to call most of the REST API we need to pass the id to same.

When we create everything from java code base we will not have any such id which was getting generated in case of UI,how I can do everything from my own custom java program without having any UI.