Configure a NiFi processor using an external file - apache-nifi

I am using NiFi to chain several API calls. I would make my flow more configurable, by setting the API keys/endpoints in an external configuration file (for example JSON, or even the nifi.properties file).
How can I use the informations in this config file in the properties of my processors?
Thank you in advance!

Currently the easiest way to do this is by setting values in bootstrap.conf which are then available through NiFi expression language. For example, if you created a new java arg like:
java.arg.15=-DmyProperty=myValue
Then in your processor, your properties need to support expression language. This is done on the property descriptor builder:
.expressionLanguageSupported(true)
Then from the UI you would set the value of that property to ${myProperty}
In a future release there is going to be a new capability to make this a little easier where you can have an external properties file that will be loaded and accessible from expression language, so you won't have to edit bootstrap.conf, but for now this is the approach.

Related

How can I set isolation-level-for-create via yaml configuration file for spring batch

I found a solution to do it via Java code here:
https://docs.spring.io/spring-batch/docs/4.2.x/reference/html/job.html#configuringJobRepository
But, I want to do it if possible in a simple way via configuration in yaml format in the batch configuration file.
Thank you.
As far as I know, there is currently no such property in yaml available.
There is an open feature request in Spring Boot (https://github.com/spring-projects/spring-boot/issues/28802) that may result in a property like spring.batch.jdbc.isolation-level-for-create in the future. Until then, you'll need to use Java (or XML) configuration.

How to set dynamic properties of processor(Nifi) using java front end

how to set properties file of processor of apache nifi from Jsp front-end using java?
It sounds pretty unnecessary since you have the NiFi UI. If you want to do so anyway, you have NiFi's Rest API so you can configure and even deploy new DataFlows with it.

Karaf 3.0.0 Configuration Admin with array values

I am trying to use configuration file to persist OSGi configuration in Karaf 3.0.0 and having some issue when using property with array of values. My configuration file is placed in /etc folder and looks something like this:
property = ["value1","value2"]
The problem is that array does not get interpreted properly, so in Web Console I see one string value instead of array of values. I figure out that if I use .config as extension for the configuration file, the array gets interpreted properly, but I experience another issue then, like for example that my config file gets overwritten. Is there any way to use .cfg extension and somehow indicate that the property is array?
You might want to take a look at the OSGi Configurer RFP and the OSGi Configurer RFC. OSGi enRoute, which inspired this upcoming spec, has a bundle and some documentation for it.
The Configurer maps JSON to (the spec will be likely YAML) to configuration admin. That said, we generally then use interfaces that define the properties so we can convert the actual configuration type to the type that the code needs automatically. This model is used in DS for configuration and (annotation interfaces in that case). OSGi enRoute has special support for this model with the DTOs service. (Which is also being specified.)

Why Sling Configuration has two different formats

in Sling, configuration can be deployed either via a sling:osgiConfig node and via a nt:file node having the configuration values.
When i make some changes in Felix Console in some configuration deployed via sling:osgiConfig node, it gets converted to nt:file format.
Why there are these two different formats for configurations in Sling. is there any significant difference between the two?
I'd say this is mostly for historical reasons, in some cases it's more convenient to provide configurations as hierarchical resources (sling:OsgiConfig) and if the config is coming from a filesystem for example, files are more convenient.
#Shashi sling:osgiConfig changing to nt:file when you make changes in felix console is expected behaviour. This will not cause any issue when you try to read the config value from java class. You will just not be able to edit the run mode config via crxde when it has changed to nt:file as it stores data as binary content.
However there is a way to disable this behaviour, you will have to uncheck "Enable Write Back" at /system/console/configMgr/org.apache.sling.installer.provider.jcr.impl.JcrInstaller as mentioned in this thread.
OSGi config best practices

Best way to get Spring Bean info from context WIHOUT creating app context?

I have a Spring (3.1.) app that has a large app-context.xml file. There is a second very small stand-alone application that needs just a few parameters from one of the beans that are configured in that xml file.
Rather than that little application instantiating the whole application context (which builds a lot of connections, etc), I just want to read in the couple of configuration parameters that are contained in that file.
I could of course create a new smaller small-app-context.xml that only has the configuration i need or put those parameters in a properties file, but then I need to maintain that information in two places, which I am trying to avoid. I know I could read in and parse the raw XML file (not exactly sure the most efficient way to do that). However, I was hoping that Spring provides a nice way to do this but I haven't found it.
Does Spring provide a clean way to do this?
Thanks.
In Spring you can have multiple configuration files. So for the part that you would like to reuse you would create a smaller, self-contained config file. It can remain in the original project and your app-context.xml can include it. Then your new, small project could include the small config xml and you wouldn't need to maintain the information in two locations.
I could of course create a new smaller small-app-context.xml that only has the configuration i need or put those parameters in a properties file
I would agree that configuration belongs in a properties file. Not the application context file. You should not be maintaining the configuration in two places. You should have the configuration once in your properties file and then make that available to any contexts which require it.

Resources