在executeScript处理器中读取外部属性

问题描述 投票:0回答:1

我在nifi.variable.registry.properties中的nifi.properties中配置了外部属性文件。我想在python中的executeScript处理器中读取这个属性。我使用过str(context.getProperty('URL'))但它没有用

apache-nifi
1个回答
3
投票

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


  • 声明ExecuteScript处理器的动态属性。例如VAR_URL = ${URL}
  • 然后在内部脚本中,您可以访问此属性:VAR_URL.evaluateAttributeExpressions(flowFile).getValue()

或者如果您不想为您的处理器声明属性并且您确定该属性在某处声明,那么您可以使用以下代码:

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

注意:不要在${URL}周围使用双引号,因为在评估nifi表达式之前,此表达式将被处理为groovy-string ...

© www.soinside.com 2019 - 2024. All rights reserved.