Jeh*_*man 0 apache-kafka apache-kafka-connect
我正在尝试将自定义转换器与Kafka Connect一起使用,但似乎无法正确使用。我希望有人对此有经验,可以帮助我解决!
我的自定义转换器的类路径为custom.CustomStringConverter
。
为避免出现任何错误,我的自定义转换器当前只是先前存在的StringConverter的副本/粘贴(当然,在我开始使用它时,它将改变)。 https://github.com/apache/kafka/blob/trunk/connect/api/src/main/java/org/apache/kafka/connect/storage/StringConverter.java
我有一个由3个节点组成的kafka connect集群,这些节点正在运行confluent的官方docker映像(confluentinc/cp-kafka-connect:3.3.0
)。
每个节点都配置为使用我的转换器加载一个jar(使用docker卷)。
当连接器启动时,它们会正确加载罐子并找到自定义转换器。确实,这是我在日志中看到的内容:
[2017-10-10 13:06:46,274] INFO Registered loader: PluginClassLoader{pluginLocation=file:/opt/custom-connectors/custom-converter-1.0-SNAPSHOT.jar} (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:199)
[2017-10-10 13:06:46,274] INFO Added plugin 'custom.CustomStringConverter' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:132)
[...]
[2017-10-10 13:07:43,454] INFO Added aliases 'CustomStringConverter' and 'CustomString' to plugin 'custom.CustomStringConverter' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:293)
Run Code Online (Sandbox Code Playgroud)
然后,我将JSON配置发布到连接器节点之一以创建我的连接器:
{
"name": "hdfsSinkCustom",
"config": {
"topics": "yellow",
"tasks.max": "1",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"value.converter": "custom.CustomStringConverter",
"connector.class": "io.confluent.connect.hdfs.HdfsSinkConnector",
"hdfs.url": "hdfs://hdfs-namenode:8020/hdfs-sink",
"topics.dir": "yellow_storage",
"flush.size": "1",
"rotate.interval.ms": "1000"
}
}
Run Code Online (Sandbox Code Playgroud)
并收到以下回复:
{
"error_code": 400,
"message": "Connector configuration is invalid and contains the following 1 error(s):\nInvalid value custom.CustomStringConverter for configuration value.converter: Class custom.CustomStringConverter could not be found.\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试运行Kafka Connect stadnalone,则错误消息是相同的。
有人面对过这个吗?我想念什么?
好的,感谢Kafka Users邮件列表中的Philip Schmitt,我找到了解决方案。
他提到了这个问题:https : //issues.apache.org/jira/projects/KAFKA/issues/KAFKA-6007,这确实是我面临的问题。
引用他的话:
为了测试这一点,我只是将我的SMT jar复制到了我正在使用的连接器的文件夹中,并调整了plugin.path属性。
确实,我通过将转换器放在连接器的文件夹中摆脱了此错误。
我还尝试了其他方法:创建一个自定义连接器,并将该自定义连接器与自定义转换器一起使用,均作为插件加载。它也可以。
摘要:转换器由连接器加载。如果您的连接器是插件,那么您的转换器也应该是。如果您的连接器不是插件(与kafka connect distrib捆绑在一起),则您的转换器也不应该是。
归档时间: |
|
查看次数: |
2666 次 |
最近记录: |