gpt4 book ai didi

java - 未调用自定义 nifi 处理器 TO Enable 注释

转载 作者:行者123 更新时间:2023-11-29 04:25:57 25 4
gpt4 key购买 nike

我有一个处理器启动与 Elasticsearch 的连接,我在一个带有 @OnEnabled 注释的方法上进行此连接,但未调用此方法:

@OnEnabled
public void onEnabled(final ConfigurationContext configurationContext) {
<code connection goes here>
}

我已经尝试了 onTrigger 方法上的连接并且它有效,但这会杀死机器。

我的处理器扩展自 AbstractProcessor 方法。

最佳答案

您可能需要在启动处理器时调用@OnScheduled,然后关闭@OnStopped 中的连接。

另一种选择是在 onTrigger 中延迟创建连接,方法是检查连接是否为空,如果为空则初始化它。

在此处查看@OnEnabled 的说明:

https://nifi.apache.org/docs/nifi-docs/html/developer-guide.html#component-lifecycle

"Note that this annotation will be ignored if applied to a ReportingTask or Processor. For a Controller Service, enabling and disabling are considered lifecycle events, as the action makes them usable or unusable by other components."

关于java - 未调用自定义 nifi 处理器 TO Enable 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46280402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com