FlinkCDC 3.2.0 新增优点 Pattern Replacement in routing rules

新增优点:Pattern Replacement in routing rules

flinkcdc 3.2.0版本相较于3.1.0版本,避免了多表多sink多次写 route 路由的麻烦,类似于统一前后缀的形式多表多sink,通过<>正则,大大减少了书写

官网:
Route | Apache Flink CDC
 

Pattern Replacement in routing rules #

If you’d like to route source tables and rename them to sink tables with specific patterns, replace-symbol could be used to resemble source table names like this:

route:
  - source-table: source_db.\.*
    sink-table: sink_db.<>
    replace-symbol: <>
    description: route all tables in source_db to sink_db

Then, all tables including source_db.XXX will be routed to sink_db.XXX without hassle.
包括source_db.XXX在内的所有表都将毫无麻烦地路由到sink_db.XXX

应用:

flinkcdc版本升级 mysql to doris 在 lib 下添加依赖jar包:

source:
  type: mysql
  hostname: xxx
  port: 3306
  username: root
  password: xxx
  tables: adb.\.*,bdb.\.*
  server-id: 6410-6490
  server-time-zone: Asia/Shanghai
  scan.startup.mode: latest-offset

sink:
  type: doris
  fenodes: xxx:8130,xxx:8130,xxx:8130
  username: root
  password: xxx
  table.create.properties.light_schema_change: true

route:
  - source-table: adb.\.*
    sink-table: test_sync.adb_db_<>
    replace-symbol: <>

pipeline:
  name: test_sync
  parallelism: 1

adb会根据route路由规则进行整库同步,bdb则会根据默认的无路由规则进行整库同步。

flinkcdc pipeline 数据库仍然需要在起任务前提前创建好,表则会在source初始阶段自动创建,表注释仍然不生效

好的,以下是 easy-rules-core 版本为 3.2.0 的使用示例代码: 首先,我们需要定义一个规则: ```java public class AgeRule extends BasicRule { private int age; public AgeRule(int priority, int age) { super("AgeRule", "Check if age is greater than 18", priority); this.age = age; } @Override public boolean evaluate(Facts facts) { int age = facts.get("age"); return age > this.age; } @Override public void execute(Facts facts) throws Exception { System.out.println("Age is greater than 18"); } } ``` 在这个规则中,我们检查一个名为 "age" 的事实是否大于18。如果是,我们将打印一条消息。 接下来,我们需要创建一个规则引擎,并将规则添加到其中: ```java Rules rules = new Rules(); rules.register(new AgeRule(1, 18)); RulesEngine rulesEngine = new DefaultRulesEngine(); rulesEngine.fire(rules, new Facts()); ``` 在这个例子中,我们创建了一个规则引擎并将 AgeRule 添加到其中。然后,我们使用一个空的 Facts 对象来启动规则引擎。 当我们运行这段代码时,因为我们提供的 "age" 事实的值为0,所以我们不会看到任何输出。 我们可以通过将 "age" 事实的值设置为20来测试规则: ```java Rules rules = new Rules(); rules.register(new AgeRule(1, 18)); Facts facts = new Facts(); facts.put("age", 20); RulesEngine rulesEngine = new DefaultRulesEngine(); rulesEngine.fire(rules, facts); ``` 当我们运行这段代码时,我们将在控制台上看到 "Age is greater than 18" 的消息。 希望这个示例能够帮助你理解如何使用 easy-rules-core 版本为 3.2.0。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SunTecTec

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值