I have sample Json file that I loaded in mongo db to be sent over to Kafka connect using debezium connector. My question how could RowKey and id key column values converted to 0's ( Zeros ) despite having valid data in raw json input file? Below are the steps followed to produce this error.
Step 1: Create sample json file
{"id":1,"first_name":"Devinne","last_name":"Stubbe","email":"[email protected]","gender":"Female","club_status":"platinum","comments":"Extended interactive initiative"}
{"id":2,"first_name":"Loise","last_name":"Salt","email":"[email protected]","gender":"Female","club_status":"silver","comments":"Optimized neutral standardization"}
{"id":3,"first_name":"Benjamen","last_name":"Spittle","email":"[email protected]","gender":"Male","club_status":"platinum","comments":"De-engineered systemic customer loyalty"}
{"id":4,"first_name":"Helena","last_name":"Pogosian","email":"[email protected]","gender":"Female","club_status":"gold","comments":"Phased hybrid definition"}
{"id":5,"first_name":"Miller","last_name":"Karolewski","email":"[email protected]","gender":"Male","club_status":"platinum","comments":"Monitored systematic software"}
Load this data in mongodb in customerprofile collection
rs0:PRIMARY> db.collection.find();
rs0:PRIMARY> db.customerprofile.find();
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5b"), "id" : 1, "first_name" :
"Devinne", "last_name" : "Stubbe", "email" : "[email protected]", "gender" :
"Female", "club_st
atus" : "platinum", "comments" : "Extended interactive initiative" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5c"), "id" : 2, "first_name" :
"Loise", "last_name" : "Salt", "email" : "[email protected]", "gender" :
"Female", "club_status"
: "silver", "comments" : "Optimized neutral standardization" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b5d"), "id" : 3, "first_name" :
"Benjamen", "last_name" : "Spittle", "email" : "[email protected]",
"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" : "[email protected]", "gender"
: "Male", "club_status" : "platinum", "comments" : "Monitored systematic
software" }
{ "_id" : ObjectId("5b6213ba78aae5dc09ef8b60"), "id" : 6, "first_name" :
"Cammy", "last_name" : "Suche", "email" : "[email protected]", "gender" :
"Male", "club_status" : "gold", "comments" : "Inverse client-server alliance"
}
Step 2: Create mongodb debezium connector config and activate the connector in kafka connect
{
"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"
}
}
step 3: Check the topic queue
ksql> print 'jsondb.jsondb.customerprofile' from beginning;
Format:JSON
{"ROWTIME":1533154567091,"ROWKEY":"
As you can see in below output debezium transformed by id column with objectid like
\"id\":\"5b6213ba78aae5dc09ef8b5b\"}","id":"5b6213ba78aae5dc09ef8b5b".
****My question how could my id column got updated with serial id key because we used JsonConvetor as key convertor? ****
{\"id\":\"5b6213ba78aae5dc09ef8b5b\"}","id":"5b6213ba78aae5dc09ef8b5b","first_name":"Devinne","last_name":"Stubbe","email":"[email protected]","gender":"Female","club_status":"platinum","comments":"Extended interactive initiative"}
{"ROWTIME":1533154567096,"ROWKEY":"
{\"id\":\"5b6213ba78aae5dc09ef8b5c\"}","id":"5b6213ba78aae5dc09ef8b5c","first_name":"Loise","last_name":"Salt","email":"[email protected]","gender":"Female","club_status":"silver","comments":"Optimized neutral standardization"}
{"ROWTIME":1533154567096,"ROWKEY":"
{\"id\":\"5b6213ba78aae5dc09ef8b5d\"}","id":"5b6213ba78aae5dc09ef8b5d","first_name":"Benjamen","last_name":"Spittle","email":"[email protected]","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":"[email protected]","gender":"Female","club_status":"gold","comments":"Phased hybrid definition"}
{"ROWTIME":1533154567097,"ROWKEY":"{\"id\":\"5b6213ba78aae5dc09ef8b5f\"}","id":"5b6213ba78aae5dc09ef8b5f","first_name":"Miller","last_name":"Karolewski","email":"[email protected]","gender":"Male","club_status":"platinum","comments":"Monitored systematic software"}
{"ROWTIME":1533154567099,"ROWKEY":"{\"id\":\"5b6213ba78aae5dc09ef8b60\"}","id":"5b6213ba78aae5dc09ef8b60","first_name":"Cammy","last_name":"Suche","email":"[email protected]","gender":"Male","club_status":"gold","comments":"Inverse client-server alliance"}
Step 4: Create a stream from the topic queue
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');
Step 5: This is where stream is receiving zero's (0's) from CUSTOMER_REPART
ksql> CREATE STREAM customers_stream WITH
(KAFKA_TOPIC='CUSTOMERS_REPART',VALUE_FORMAT='json',PARTITIONS=1) as SELECT *
FROM customers_profile PARTITION BY id;
Step 6: Please check the output from this print command where it shows Zero's in ROWKEY and id key column values. Where did they came from? What I need to do to make sure the ROWKEY and id key column shows correct values from raw json file values that were originally loaded in mongodb?
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
{"ROWTIME":1533154567091,"ROWKEY":"0","CLUB_STATUS":"platinum","GENDER":"Female","COMMENTS":"Extended interactive initiative","ID":0,"LAST_NAME":"Stubbe","EMAIL":"dstubbe0@ {"ROWTIME":1533154567096,"ROWKEY":"0","CLUB_STATUS":"silver","GENDER":"Female","COMMENTS":"Optimized neutral standardization","ID":0,"LAST_NAME":"Salt","EMAIL":"lsalt1@appl {"ROWTIME":1533154567096,"ROWKEY":"0","CLUB_STATUS":"platinum","GENDER":"Male","COMMENTS":"De-engineered systemic customer loyalty","ID":0,"LAST_NAME":"Spittle","EMAIL":"bs":"Benjamen"} {"ROWTIME":1533154567097,"ROWKEY":"0","CLUB_STATUS":"gold","GENDER":"Female","COMMENTS":"Phased hybrid definition","ID":0,"LAST_NAME":"Pogosian","EMAIL":"hpogosian3@pagespe {"ROWTIME":1533154567097,"ROWKEY":"0","CLUB_STATUS":"platinum","GENDER":"Male","COMMENTS":"Monitored systematic software","ID":0,"LAST_NAME":"Karolewski","EMAIL":"mkarolews {"ROWTIME":1533154567099,"ROWKEY":"0","CLUB_STATUS":"gold","GENDER":"Male","COMMENTS":"Inverse client-server alliance","ID":0,"LAST_NAME":"Suche","EMAIL":"[email protected] {"ROWTIME":1533154567104,"ROWKEY":"0","CLUB_STATUS":"platinum","GENDER":"Male","COMMENTS":"Phased uniform software","ID":0,"LAST_NAME":"Suttling","EMAIL":"msuttling7@baidu. {"ROWTIME":1533154567104,"ROWKEY":"0","CLUB_STATUS":"gold","GENDER":"Female","COMMENTS":"Quality-focused global software","ID":0,"LAST_NAME":"Stepney","EMAIL":"estepney8@we