Created 05-27-2018 05:55 PM
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.
Created on 05-27-2018 07:35 PM - edited 08-17-2019 10:05 PM
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:
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".
Created on 05-27-2018 07:35 PM - edited 08-17-2019 10:05 PM
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:
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".
Created 05-27-2018 10:48 PM
Thanks Matt, that did the trick!
Created 12-06-2018 03:01 PM
Is there a way (without using execute script) to modify the processor_group variable in processor?