明确为Kafka KTable设置密钥

时间:2017-10-31 07:28:21

标签: java

我有一条Json消息,我想通过Kafka KTable进行处理。 消息是: { "table": "TEST.S_ORDER_ITEM", "op_type": "I", "op_ts": "test1", "current_ts": "2017-07-28T09:09:45.022000", "pos": "00000000010000006413", "after": { "ROW_ID": "2-21DSRY", "LAST_UPD": "2014-05-24:00:00:00", "ORDER_ID": "2-21DSRY", "LAST_UPD_BY": "0-1", "ACTIVE_FLG": "WCW==", "BU_ID": "1-ENQCIQ", "ORDER_NUM": "2-96612816484", "REV_NUM": "1", "ORDER_DT": "2014-05-24:00:00:00", "REQ_SHIP_DT": "2014-06-10:00:00:00", "ACCNT_ID": "1-1G9MA10", "CONTACT_ID": "1-1GGZ1LF", "INTEGRATION_ID": null, "QUOTE_ID": null, "SHIP_CON_ID": "1-1GGZ1LF", "STATUS_CD": "Pending", "X_CLOSE_DT": null, "X_CUST_REF": "548304383-761", "X_SUB_STAT": "COMPLETE", "PROCESS_TIMESTAMP": "2017-04-19:15:27:34.786214000", "SOFT_DELETE": "N" } }

是否可以让KTable以KTable格式存储数据,其中密钥将是上述消息中的ROW_ID。

我可以使用KStream做同样的事情,但问题是每次我想要更新数据。 我在KStream中使用了相同的方法:

 KStream<String, JsonNode> orderstre = streams.filter((k, v) -> v.path("table").asText      ().equals("TEST.S_ORDER"))
             .map((k, v) -> KeyValue.pair(v.path("after").path("ROW_ID").asText(), v));

0 个答案:

没有答案