首页 > 解决方案 > 如何处理或创建从 kafka 接收的从 Neo4j 流发出的数据的模型类?

问题描述

我试图了解从 Neo4j 流向一个 kafka 主题发出的 kafka 的接收模型。

实际上,该数据如下所示。

{
  "meta": {
    "timestamp": 1608725179199,
    "username": "neo4j",
    "txId": 16443,
    "txEventId": 0,
    "txEventsCount": 1,
    "operation": "created",
    "source": {
      "hostname": "9945"
    }
  },
  "payload": {
    "id": "1000",
    "before": null,
    "after": {
      "properties": {
        "name": "sdfdf"
      },
      "labels": [
        "aaq"
      ]
    },
    "type": "node"
  },
  "schema": {
    "properties": {
      "name": "String"
    },
    "constraints": []
  }
}

那么要在kafka的springboot中使用这种复杂的结构化数据,我们需要创建嵌套模型吗?

我的意思是近 4 个类相互嵌套?

据我了解,我正在尝试创建以下类。

meta (**This is 1st class**)
    "operation": "created",

payload(**This is 2ndclass which is nested inside the Meta**)
    id
    before
    after(**it is 3rd class which is nested to payload**)

        properties(**it is 4th class which is nested with in after**)
            these data only we needed to store
        labels
    type

实际上我之前没有遇到过这种嵌套问题,所以不知道如何处理?

那么上述方法是正确的还是有其他可能性?

最终目标是必须消费来自 kafka 主题的由 Neo4j 流发出的数据吗?

语言:Java

框架:Springboot

标签: spring-bootapache-kafkaneo4jconfluent-platform

解决方案


推荐阅读