java包中接收器连接器的实现

时间:2020-10-28 10:05:11

标签: java apache-kafka apache-kafka-connect

我已经启动了zookeeper,kafka服务器,kafka生产者和kafka消费者,并且我把从confluent下载的jdbc sql连接器jar放入了jar,并将其放在路径中,并且我在connect-standalone属性中提到了plugin.path。运行connect-standalone.bat .... \ config \ connect-standalone.properties .... \ config \ sink-quickstart-mysql.properties,没有任何错误,但是有很多警告,并且没有开始,但是我的数据没有反映在表格中。我错过了什么?您能帮我吗?我有以下警告

                                                                                                    org.reflections.ReflectionsException: could not get type for name io.netty.inter
nal.tcnative.SSLPrivateKeyMethod
        at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:312)
        at org.reflections.Reflections.expandSuperTypes(Reflections.java:382)
        at org.reflections.Reflections.<init>(Reflections.java:140)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader$Inte
rnalReflections.<init>(DelegatingClassLoader.java:433)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scan
PluginPath(DelegatingClassLoader.java:325)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scan
UrlsAndAddPlugins(DelegatingClassLoader.java:261)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.init
PluginLoader(DelegatingClassLoader.java:209)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.init
Loaders(DelegatingClassLoader.java:202)
        at org.apache.kafka.connect.runtime.isolation.Plugins.<init>(Plugins.jav
a:60)
        at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone
.java:79)
Caused by: java.lang.ClassNotFoundException: io.netty.internal.tcnative.SSLPriva
teKeyMethod
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:310)
        ... 9 more

1 个答案:

答案 0 :(得分:0)

除非您需要将kafka连接到某些奇异的数据源,否则无需自己编写源连接器。像mysql这样的流行工具已经被很好地介绍了。合流的“ jdbc连接器”已经可以满足您的要求。

https://docs.confluent.io/current/connect/kafka-connect-jdbc/index.html

您将需要一个有效的kafka-connect安装,然后可以使用HTTP POST到kafka connect API将mysql表“连接”到kafka。只需在tables.whitelist属性中指定要用作来源的表的逗号分隔列表即可。例如,类似这样的东西...

curl -X POST $KAFKA_CONNECT_API/connectors -H "Content-Type: application/json" -d '{
      "name": "jdbc_source_mysql_01",
      "config": {
              "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
              "connection.url": "jdbc:mysql://mysql:3306/test",
              "connection.user": "connect_user",
              "connection.password": "connect_password",
              "topic.prefix": "mysql-01-",
              "poll.interval.ms" : 3600000,
              "table.whitelist" : "test.accounts",
              "mode":"bulk"
              }
      }'