如何配置kafka集群进行批处理

时间:2017-09-12 13:33:56

标签: jdbc apache-kafka apache-kafka-connect confluent

我试图使用Kafka connect向DB(使用者)提供一定数量的新行。我已将源配置文件配置为

这是source.properties的外观:

var responseTask = client.someRemoteCall(request);

responseTask.ContinueWith(t =>
{
    switch (t.Status)
    {
        case TaskStatus.Faulted:
            foreach (var exception in t.Exception.Flatten().InnerExceptions)
            {
                log.Error(exception.Message);

                if (exception.InnerException != null)
                {
                    log.Error(exception.InnerException.Message);
                }
            }
            break;
        case TaskStatus.RanToCompletion:
            {your success code}
        default:
            {some deafult error is thrown}
    }
});

这是接收器属性文件的内容

 name=source-postgres
 connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
 tasks.max=1
 batch.max.rows = 10
 connection.url=jdbc:postgresql://<URL>/postgres?user=postgres&password=post
 mode=timestamp+incrementing
 timestamp.column.name=updated_at
 incrementing.column.name=id
 topic.prefix=postgres_

但这没有任何效果,每当有新行可用时,它就会被插入到DB(消费者)中。所以,我在接收器name=dbx-sink batch.size=5 connector.class=io.confluent.connect.jdbc.JdbcSinkConnector tasks.max=1 # The topics to consume from - required for sink connectors like this one topics=postgres_users # Configuration specific to the JDBC sink connector. # We want to connect to a SQLite database stored in the file test.db and auto-create tables. connection.url=jdbc:postgresql://<URL>:35000/postgres?user=dba&password=nopasswd auto.create=true 中添加了另一个配置参数。这也没有效果。

当我启动connect-standalone.sh脚本时,我可以在控制台上看到batch.max.rows = 10.

我做错了什么或如何解决?

1 个答案:

答案 0 :(得分:1)

batch.max.rows每批将发送10行;它不会限制总共发送的行数。