debeziumコネクタを使用してKafka接続に送信するために、mongo dbにロードしたサンプルのJsonファイルがあります。私の質問は、生のjson入力ファイルに有効なデータがあるにもかかわらず、RowKeyおよびidキー列の値が0(ゼロ)に変換されるのはなぜですか? 以下は、このエラーを生成するための手順です。
ステップ 1: サンプル json ファイルを作成する
{"id":1,"first_name":"Devinne","last_name":"Stubbe","email":"dstubbe0@java.com","gender":"Female","club_status":"platinum","comments":"Extended interactive initiative"}
{"id":2,"first_name":"Loise","last_name":"Salt","email":"lsalt1@apple.com","gender":"Female","club_status":"silver","comments":"Optimized neutral standardization"}
{"id":3,"first_name":"Benjamen","last_name":"Spittle","email":"bspittle2@howstuffworks.com","gender":"Male","club_status":"platinum","comments":"De-engineered systemic customer loyalty"}
{"id":4,"first_name":"Helena","last_name":"Pogosian","email":"hpogosian3@pagesperso-orange.fr","gender":"Female","club_status":"gold","comments":"Phased hybrid definition"}
{"id":5,"first_name":"Miller","last_name":"Karolewski","email":"mkarolewski4@g.co","gender":"Male","club_status":"platinum","comments":"Monitored systematic software"}
このデータを mongodb の customerprofile コレクションにロードします
rs0:PRIMARY> db.collection.find();
rs0:PRIMARY> db.customerprofile.find();
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5b"), "id" : 1, "first_name" :
"Devinne", "last_name" : "Stubbe", "email" : "dstubbe0@java.com", "gender" :
"Female", "club_st
atus" : "platinum", "comments" : "Extended interactive initiative" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5c"), "id" : 2, "first_name" :
"Loise", "last_name" : "Salt", "email" : "lsalt1@apple.com", "gender" :
"Female", "club_status"
: "silver", "comments" : "Optimized neutral standardization" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5d"), "id" : 3, "first_name" :
"Benjamen", "last_name" : "Spittle", "email" : "bspittle2@howstuffworks.com",
"gender" : "Male"
, "club_status" : "platinum", "comments" : "De-engineered systemic customer
loyalty" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5e"), "id" : 4, "first_name" :
"Helena", "last_name" : "Pogosian", "email" : "hpogosian3@pagesperso-
orange.fr", "gender" : "Fe
male", "club_status" : "gold", "comments" : "Phased hybrid definition" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5f"), "id" : 5, "first_name" :
"Miller", "last_name" : "Karolewski", "email" : "mkarolewski4@g.co", "gender"
: "Male", "club_status" : "platinum", "comments" : "Monitored systematic
software" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b60"), "id" : 6, "first_name" :
"Cammy", "last_name" : "Suche", "email" : "csuche5@cbsnews.com", "gender" :
"Male", "club_status" : "gold", "comments" : "Inverse client-server alliance"
}
ステップ 2: mongodb debezium コネクタ構成を作成し、kafka 接続でコネクタをアクティブ化する
{
"name": "mongodb-jsondb-connector",
"config":{
"connector.class": "io.debezium.connector.mongodb.MongoDbConnector",
"mongodb.hosts": "rs0/169.254.57.118:27017",
"mongodb.name": "jsondb",
"mongodb.members.auto.discover": "false",
"database.whitelist": "jsondb",
"transforms": "unwrap",
"transforms.unwrap.type":
"io.debezium.connector.mongodb.transforms.UnwrapFromMongoDbEnvelope",
"database.history.kafka.topic": "schema-changes.jsondb",
"key.converter": "org.apache.kafka.connect.json.JsonConverter",
"key.converter.schemas.enable": "false",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"value.converter.schemas.enable": "false"
}
}
ステップ 3: トピック キューを確認する
ksql> print 'jsondb.jsondb.customerprofile' from beginning;
Format:JSON
{"ROWTIME":1533154567091,"ROWKEY":"
以下の出力 debezium でわかるように、objectid を持つ id 列によって変換されます。
\"id\":\"5b6213ba78aae5dc09ef8b5b\"}","id":"5b6213ba78aae5dc09ef8b5b".
****私の質問は、JsonConvetor をキー コンバーターとして使用したため、ID 列がシリアル ID キーでどのように更新されたのでしょうか? ****
{\"id\":\"5b6213ba78aae5dc09ef8b5b\"}","id":"5b6213ba78aae5dc09ef8b5b","first_name":"Devinne","last_name":"Stubbe","email":"dstubbe0@java.com","gender":"Female","club_status":"platinum","comments":"Extended interactive initiative"}
{"ROWTIME":1533154567096,"ROWKEY":"
{\"id\":\"5b6213ba78aae5dc09ef8b5c\"}","id":"5b6213ba78aae5dc09ef8b5c","first_name":"Loise","last_name":"Salt","email":"lsalt1@apple.com","gender":"Female","club_status":"silver","comments":"Optimized neutral standardization"}
{"ROWTIME":1533154567096,"ROWKEY":"
{\"id\":\"5b6213ba78aae5dc09ef8b5d\"}","id":"5b6213ba78aae5dc09ef8b5d","first_name":"Benjamen","last_name":"Spittle","email":"bspittle2@howstuffworks.com","gender":"Male","club_status":"platinum","comments":"De-engineered systemic customer loyalty"}
{"ROWTIME":1533154567097,"ROWKEY":"{\"id\":\"5b6213ba78aae5dc09ef8b5e\"}","id":"5b6213ba78aae5dc09ef8b5e","first_name":"Helena","last_name":"Pogosian","email":"hpogosian3@pagesperso-orange.fr","gender":"Female","club_status":"gold","comments":"Phased hybrid definition"}
{"ROWTIME":1533154567097,"ROWKEY":"{\"id\":\"5b6213ba78aae5dc09ef8b5f\"}","id":"5b6213ba78aae5dc09ef8b5f","first_name":"Miller","last_name":"Karolewski","email":"mkarolewski4@g.co","gender":"Male","club_status":"platinum","comments":"Monitored systematic software"}
{"ROWTIME":1533154567099,"ROWKEY":"{\"id\":\"5b6213ba78aae5dc09ef8b60\"}","id":"5b6213ba78aae5dc09ef8b60","first_name":"Cammy","last_name":"Suche","email":"csuche5@cbsnews.com","gender":"Male","club_status":"gold","comments":"Inverse client-server alliance"}
ステップ 4: トピック キューからストリームを作成する
CREATE STREAM customers_profile \
(id integer, first_name string, last_name string, \
email string, gender string, club_status string, \
comments string) WITH \
(KAFKA_TOPIC='jsondb.jsondb.customerprofile',VALUE_FORMAT='json');
ステップ 5: これは、ストリームが CUSTOMER_REPART からゼロ (0) を受け取る場所です。
ksql> CREATE STREAM customers_stream WITH
(KAFKA_TOPIC='CUSTOMERS_REPART',VALUE_FORMAT='json',PARTITIONS=1) as SELECT *
FROM customers_profile PARTITION BY id;
ステップ 6: この print コマンドの出力を確認してください。ここでは、ROWKEY と ID キー列の値にゼロが表示されています。彼らはどこから来たのですか?ROWKEY および id キー列が、最初に mongodb にロードされた未加工の json ファイルの値から正しい値を表示するようにするには、どうすればよいですか?
ksql> SET 'auto.offset.reset' = 'earliest';
Successfully changed local property 'auto.offset.reset' from 'null' to
'earliest'
ksql> print 'CUSTOMERS_REPART' from beginning;
Format:JSON
"Male","COMMENTS":"逆クライアント サーバー アライアンス","ID":0,"LAST_NAME":"Suche","EMAIL":"csuche5@cbsnews.c {"ROWTIME":1533154567104,"ROWKEY" :"0","CLUB_STATUS":"platinum","GENDER":"Male","COMMENTS":"フェイズユニフォームソフト","ID":0,"LAST_NAME":"サットリング","EMAIL":" msuttling7@baidu. {"ROWTIME":1533154567104,"ROWKEY":"0","CLUB_STATUS":"gold","GENDER":"女性","COMMENTS":"品質重視のグローバルソフト","ID":0," LAST_NAME":"Stepney","EMAIL":"estepney8@we 段階的な統一ソフトウェア","ID":0,"LAST_NAME":"Suttling","EMAIL":"msuttling7@baidu. {"ROWTIME":1533154567104,"ROWKEY":"0","CLUB_STATUS":"gold","GENDER":"女性","COMMENTS":"品質重視のグローバルソフト","ID":0," LAST_NAME":"Stepney","EMAIL":"estepney8@we 段階的な統一ソフトウェア","ID":0,"LAST_NAME":"Suttling","EMAIL":"msuttling7@baidu. {"ROWTIME":1533154567104,"ROWKEY":"0","CLUB_STATUS":"gold","GENDER":"女性","COMMENTS":"品質重視のグローバルソフト","ID":0," LAST_NAME":"Stepney","EMAIL":"estepney8@we