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

查看:26
本文介绍了如何在“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"服务,其中包含所有必需的详细信息,其name"属性类似于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. 输入文件的属性

推荐答案

检查 其他细节 ExecuteGroovyScript 处理器

对于所有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天全站免登陆