Databus Clients

概述

Databus Clients主要负责以下几个工作:

  • 通过Databus Relays restful 服务,检查新的数据变化事件,并处理业务逻辑(如同步数据、保存入缓存服务等);
  • 如果与relays的连接断开时间太长(SCN号差别大),会向bootstrap server发送一个查询请求;
  • 新的客户端向bootstrap server查询之后,切换到relays获取最近的数据变化事件;
  • 客户端可以单独的部署处理所有的databus relays事件,也可以主从部署,每个消费端只消费一部分事件;

技术架构

  • Relay Connection:从relay端实时的获取数据变化事件;
  • Bootstrap Connection:从Bootstrap Server获取回溯的数据;
  • Dispatcher:读取数据变化事件并分发事件;
  • Consumer Code Callbacks:分发回调,一般Client端需要实现这个接口进行业务处理;
  • Checkpoint persistence:持久化Checkpoint。

Configure-client配置

目前已经对于Clients做了简单的封装,一般性的数据同步只需要修改配置即可;

  1. 配置conf/db.properties

    db.properties
    jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
    jdbc.url=jdbc:oracle:thin:databus/databus @10 .10. 111.5 : 1521 :testafc
    jdbc.username=databus
    jdbc.password=databus
    jdbc.pool.min.size= 1
    jdbc.pool.max.size= 3
  2. 配置conf/client.properties

    client.properties
    databus.client.connectionDefaults.pullerRetries.initSleep= 1
    databus.client.checkpointPersistence.fileSystem.rootDirectory=./client-checkpoints
    databus.client.checkpointPersistence.clearBeforeUse= false
    databus.client.connectionDefaults.enablePullerMessageQueueLogging= false
    databus.client.container.jmx.rmiEnabled= false
    databus.client.container.httpPort= 9001
    databus.client.runtime.relay( 1 ).host=localhost(relay IP)
    databus.client.runtime.relay( 1 ).port= 11115
    databus.client.runtime.relay( 1 ).sources=com.lefu.boss.UNION_PAY_BCN_32_CONFIG

    注意修改 Databus Relays数据抓取端的IP;sources的名字和relay的sources.name必须一致,如果包含多个用逗号隔开即可。

  3. 配置conf/configure.xml

    <? xml  version = "1.0"  encoding = "UTF-8" ?>
    < configure >
         < source  name = "com.lefu.boss.UNION_PAY_BCN_32_CONFIG"  id = "117"
             table = "posp_trans.UNION_PAY_BCN_32_CONFIG"  db = "oracle" >
             < fields >
                 < field  name = "ID"  alias = "key"  primaryKey = "true"  type = "long"  />
                 < field  name = "OPTIMISTIC"  type = "long"  />
                 < field  name = "BANK_CUSTOMER_NO"  />
                 < field  name = "STATUS"  />
                 < field  name = "LEFU_ORG_CODE"  />
                 < field  name = "CUSTOMER_NAME"  />
             </ fields >
         </ source >
    </ configure >

    注意:

    每个表对应一个source

    id必须与relay中sources.id一致

    name必须与relay中sources.name一致

    table:表名(根据数据库选择是否添加用户名)

    db:必须指明是oracle还是mysql

    fileds.name:字段名称

    fields.alias:别名(源字段),默认与name相同

    fields.primarykey:是否组件(默认为false)

    fields.type:字段类型

  4. 启动client

    startup.sh
    ./bin/startup.sh


至此,对于Databus Clients的配置就配置完成了!

猜你喜欢

转载自blog.csdn.net/du_minchao/article/details/68928106