文档

动态路由

更新时间:

本文介绍如何使用数据清洗功能中的动态路由模板处理消息数据。

使用示例

例如,以下是一份牙膏信息清单。

message:
[BrandA, toothpaste, $12.98, 100g
 BrandB, toothpaste, $7.99, 80g
 BrandC, toothpaste, $1.99, 100g]

需要按照自定义动态规则,将列表路由至目标Topic。规则描述如下所示。

  • 如果消息以BrandA开头,发送至BrandA-item-topic和BrandA-discount-topic这两个topic。

  • 如果消息以BrandB开头,发送至BrandB-item-topic和BrandB-discount-topic这两个topic。

  • 其余消息发送至Unknown-brand-topic。

规则的JSON描述如下。

{
  "defaultTopic": "Unknown-brand-topic",
  "rules": [
    {
      "regex": "^BrandA",
      "targetTopics": [
        "BrandA-item-topic",
        "BrandA-discount-topic"
      ]
    },
    {
      "regex": "^BrandB",
      "targetTopics": [
        "BrandB-item-topic",
        "BrandB-discount-topic"
      ]
    }
  ]
}

dataclean_dynamicroute