Kafka 连接器可以加载自己的名称吗?

Can a Kafka Connector load its own name?

根据 Kafka 文档

Connector configurations are simple key-value mappings. For standalone mode these are defined in a properties file and passed to the Connect process on the command line.

Most configurations are connector dependent, so they can't be outlined here. However, there are a few common options:

name - Unique name for the connector. Attempting to register again with the same name will fail.

我在独立模式下有 10 个连接器 运行:

bin/connect-standalone.sh config/connect-standalone.properties connector1.properties connector2.properties ...

我的问题是连接器可以在运行时加载自己的名称吗?

提前致谢。

是的,您可以在运行时获取连接器的名称。

当连接器启动时,所有属性都传递给 Connector::start(Map<String, String> props)。连接器可以读取这些属性、验证它们、保存并稍后传递给 Task。他用不用取决于Connector的实现。

连接器名称 属性 是 name