如何在'ExecuteGroovyScript'处理器中使用'DBCPConnectionPoolLookup'控件服务 [英] How to use 'DBCPConnectionPoolLookup' controllor service in 'ExecuteGroovyScript' processor

查看:61
本文介绍了如何在'ExecuteGroovyScript'处理器中使用'DBCPConnectionPoolLookup'控件服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据输入流文件中发送给ExecuteGroovyStript处理器的'database.name'属性访问多个数据库.

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

在"ExecuteGroovyStript"处理器中,我有一个属性"SQL.clientdb",它指向查找"服务.同时,我已经调试了一个"DBCPConnectionPool"服务,该服务具有所有必需的详细信息及其名称"属性,类似于"database.name"的值.我尝试访问池服务的方式是: def clientDb = SQL.clientdb.getConnection(flowFile.getAttributes())

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())

运行Groovy处理器后收到的错误是 org.apache.nifi.processor.exception.ProcessException:属性必须包含属性名称"database.name":org.apache.nifi.processor.exception.ProcessException:属性必须包含属性名称"database.name"

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. "ExecuteScript"的配置
  2. 连接池服务
  3. 输入文件的属性

推荐答案

检查对于所有 SQL.* 参数,在触发时自动从相应的连接池获取与数据库的连接.和 SQL.xxx 变量引用 groovy.sql.Sql对象

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

如果要访问任何控制器服务,请在参数中使用 CTL.前缀.

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

在这种情况下,变量 CTL.xxx 直接提供了到ControllerService的链接.

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

这篇关于如何在'ExecuteGroovyScript'处理器中使用'DBCPConnectionPoolLookup'控件服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆