Scenario: I am working on change data capture application (Azure cosmosDB, Java8). I am reading the data from cosmos via change stream processor. I need to update the keys (column names) of the received Bson document and push it to Kafka topic. One way I tried is:
- Convert document to json
- Use json mapper to update the keys
- Convert json back to document
Is there any better way to achieve the same?
Original document
"_id" -> {Document@13179} size = 2
key = "_id"
value = {Document@13179} size = 2
"LnNbr" -> {Integer@13392} 205
"pId" -> {Integer@13394} 1169700246
"partitionKey" -> "1169700246|205"
"pId" -> {Integer@13183} 1169700246
"LnNbr" -> {Integer@13185} 205
"bizStatCd" -> "A"
"itmNbr" -> {Integer@13189} 574236754
Converted Document
"_id" -> {Document@13179} size = 2
key = "_id"
value = {Document@13179} size = 2
"lineNumber" -> {Integer@13392} 205
"orderId" -> {Integer@13394} 1169700246
"partitionKey" -> "1169700246|205"
"orderId" -> {Integer@13183} 1169700246
"lineNumber" -> {Integer@13185} 205
"businessCode" -> "A"
"itemNumber" -> {Integer@13189} 574236754