happy
happy

Reputation: 2628

Read external properties in executeScript processor

I have an external properties file configured in nifi.properties in nifi.variable.registry.properties . I want to read this property in executeScript processor in python. I have used str(context.getProperty('URL')) but its not working

Upvotes: 1

Views: 2039

Answers (1)

daggett
daggett

Reputation: 28634

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-scripting-nar/1.9.1/org.apache.nifi.processors.script.ExecuteScript/index.html


  • declare a dynamic property for the ExecuteScript processor. for example VAR_URL = ${URL}
  • then inside script you can access this property: VAR_URL.evaluateAttributeExpressions(flowFile).getValue()

or if you don't want to declare property for your processor and you are sure the property declared somewhere, then you can use the following code:

context.newPropertyValue( '${URL}' ).evaluateAttributeExpressions().getValue()

Note: don't use double quotes around ${URL} because this expression will be processed as a groovy-string before evaluating nifi expression...

Upvotes: 6

Related Questions