How to use 'DBCPConnectionPoolLookup' controllor service in 'ExecuteGroovyScript' processor

こ雲淡風輕ζ 提交于 2020-02-23 07:25:08

问题


I want to access multiple databases depending on the 'database.name' attribute sent in the input flowfile to ExecuteGroovyStript processor.

In 'ExecuteGroovyStript' processor I have a property 'SQL.clientdb' which point to 'lookup' service. At the same time I have commissioned a 'DBCPConnectionPool' service with all the required details and its 'name' property similar to value of 'database.name'. The way in which I'm trying to access the pool service is: def clientDb = SQL.clientdb.getConnection(flowFile.getAttributes())

Error which I receive after running the Groovy processor is org.apache.nifi.processor.exception.ProcessException: Attributes must contain an attribute name 'database.name': org.apache.nifi.processor.exception.ProcessException: Attributes must contain an attribute name 'database.name'

Please find below links of images which shows further details:

  1. Configuration of 'ExecuteScript'
  2. Connection pool services
  3. Attributes of input file

回答1:


Check the additional details documentation of the ExecuteGroovyScript processor

For all SQL.* parameters connection to the database obtained from corresponding connection pool automatically on trigger. And SQL.xxx variable references groovy.sql.Sql object

If you want to access any controller service - use CTL. prefix for your parameter.

In this case the variable CTL.xxx provides a link to a ControllerService directly.



来源:https://stackoverflow.com/questions/57883900/how-to-use-dbcpconnectionpoollookup-controllor-service-in-executegroovyscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!