Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NiFi: Is it possible to access Processor Group variables within ExectueScript?

Solved Go to solution

NiFi: Is it possible to access Processor Group variables within ExectueScript?

New Contributor

Hey Guys,

Is it possible to access the Processor Group variables within the ExecuteScript Processor? I would specifically be interested in the syntax for doing that with Ruby.

Any guidance would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: NiFi: Is it possible to access Processor Group variables within ExectueScript?

The variables are in a ComponentVariableRegistry which is pretty well-hidden under the NiFi API. Usually you get at variables by evaluating Expression Language in the context of a processor property. In this case I set a Process Group variable called "myAttr" to "myValue", then I configured ExecuteScript like so:

77400-useprocessgroupvariable.png

Note that I created a user-defined property "myProp" whose value is an expression language construct containing the PG variable name. When you call evaluateAttributeExpressions() on that property (see the script) it will resolve the value of "myAttr" and return that, you can verify that an outgoing flow file would now have "myFlowFileAttr" set to "myValue".

3 REPLIES 3

Re: NiFi: Is it possible to access Processor Group variables within ExectueScript?

The variables are in a ComponentVariableRegistry which is pretty well-hidden under the NiFi API. Usually you get at variables by evaluating Expression Language in the context of a processor property. In this case I set a Process Group variable called "myAttr" to "myValue", then I configured ExecuteScript like so:

77400-useprocessgroupvariable.png

Note that I created a user-defined property "myProp" whose value is an expression language construct containing the PG variable name. When you call evaluateAttributeExpressions() on that property (see the script) it will resolve the value of "myAttr" and return that, you can verify that an outgoing flow file would now have "myFlowFileAttr" set to "myValue".

Highlighted

Re: NiFi: Is it possible to access Processor Group variables within ExectueScript?

New Contributor

Thanks Matt, that did the trick!

Re: NiFi: Is it possible to access Processor Group variables within ExectueScript?

New Contributor

Is there a way (without using execute script) to modify the processor_group variable in processor?