问题
According to Kafka Documentation
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.
I have 10 connectors running in standalone mode like this:
bin/connect-standalone.sh config/connect-standalone.properties connector1.properties connector2.properties ...
My question is can a connector load its own name at runtime?
Thanks in advance.
回答1:
Yes, you can get the name of the connector at runtime.
When connector starts all properties are passed to Connector::start(Map<String, String> props)
. Connector can read those properties, validate them, save and later pass to Task
. It depends on Connector implementation if he use it or not.
Connector name property is name
.
来源:https://stackoverflow.com/questions/55301475/can-a-kafka-connector-load-its-own-name