如何解决处理具有通过多个现有字段引用其他类型的动态字段的消息
让我们考虑一个提供送货服务的零售商/餐厅连锁店:
- 每个仓库/餐厅都会发送报告不同事件的状态消息(此类消息很可能并不总是包含相同的字段),例如:
type: restaurant.status
msg_timestamp
restaurant_id
number_of_orders_last_30_min
number_of_orders_last_60_min
或
type: restaurant.status
msg_timestamp
restaurant_id
offer_of_the_day
- 客户订购与餐厅相关的某些产品:
type: order.status
msg_timestamp
product.type: product.status
product.info
order_id
order_timestamp
restaurant_id
product.type
和product.info
是另一条描述产品(价格,库存,...)的消息,但也有restaurant_id
。
或
type: order.status
msg_timestamp
completion_degree
order_id # only unique for open orders of a restaurant
order_timestamp
restaurant_id
因此order_id
,order_timestamp
和restaurant_id
唯一地定义了一个订单,但没有唯一地定义初始订单消息。
当然,可能会有更多的状态类型,例如对于客户而言,实际交货时间是
我无法更改原始消息。但是我可以在Kafka中进行某些预处理。
- Kafka中的状态消息可能没有正确的时间戳顺序,例如在发布新订单之前不久,更新的产品可能会比订单晚被摄取。
- order_timestamp与实际交付之间的时间范围可能太大,以至于无法同时依靠这两个消息。
问题:哪些图形数据库适合此类数据?如何处理邮件? 最好的情况是,边缘会由数据库本身内部的某些逻辑生成(即使消息时间戳之间的时间范围更大),例如(建议):
- 从订单到产品:使用相同的
product.status
处理所有restaurant_id
类型的消息。选择order_timestamp
之前的最新版本(因为价格或库存变化)。 - 从交付到订购:从
order.status
,restaurant_id
和order_timestamp
到所有类型为order_id
的邮件,然后选择带有product.info
字段的邮件。
由于性能影响,我担心通过更新文档将一个订单的消息合并在一起是不可行的吗?然后order_id
,order_timestamp
和restaurant_id
将为文档定义唯一的ID。
感谢您的帮助!谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。