开发者社区> 问答> 正文

如何配置订阅通道



描述


通过这个接口进行数据订阅任务的配置,包括实例连接信息,迁移对象等。在任务成功启动之前,可以多次调用这个接口进行任务配置的修改。目前只支持RDS MySQL类型实例的数据订阅。

请求参数

参数名称数据类型是否必须参数描述
ActionString系统参数,为这个接口的接口定义,取值为:ConfigureSubscriptionInstance
SubscriptionInstanceIdString需要配置的订阅通道ID
SubscriptionInstanceNameString订阅通道名称,可用于识别订阅通道
SourceEndpoint.InstanceTypeString订阅实例类型,取值为:RDS 默认取值为:RDS
SourceEndpoint.InstanceIdStringRDS实例ID
SubscriptionDataType.DDLBoolean订阅的数据类型,包括DDL结构更新如果需要订阅DDL取值为true,否则为false默认取值为:true
SubscriptionDataType.DMLBoolean订阅的数据类型,包括DML数据更新如果需要订阅DML取值为true,否则为false默认取值为:true
SubscriptionObjectsList源实例的监听端口,当源实例为自建数据库时必填,SubscriptionObject的具体定义详见下面的SubscriptionObject参数定义


SubscriptionObject参数定义


SubscriptionObject 的定义格式为 JSON字符串,且对象配置支持一定的正则表达式。
SubscriptionObject的定义如下: SubscriptionObject:{
        DBName:"待订阅的库名",
        TableIncludes:[{
                   TableName: "待迁移表表名"
        }]
}


其中:SubscriptionObject为订阅对象白名单。
各种对象名的定义可以支持如下的正则表达式:
  • 点号 . 表示匹配除’\r\n’之外的任何单个字符
  • 星号 * 表示匹配前面子表达式任意次,h.*llo匹配hllo, heeeello等字符串
  • 问号 ?表示匹配前面子表达式零次或1次,h.?llo 匹配hllo,hello,但不能匹配haello
  • [characters] 字符集合,表示匹配方括号内任意一个字符,例如h[aello]匹配hallo, hello
  • [^characters] 负值字符集合,表示不匹配方括号内任意一个字符,例如h[^ae]llo匹配hcllo,hdllo,但是不能匹配hallo, hello
  • [character1-character2] 字符范围,表示character1-character2范围内的字符都可以匹配,例如[0-9],[a-z]


返回参数

参数名称数据类型参数说明
RequestIdString请求的唯一标识
SuccessString请求是否成功,返回true或者false
ErrCodeString错误码
ErrMessageString错误详细内容


示例


下面简单演示通过JAVA SDK 配置迁移任务的示例: private static void configureSbeJob(String MigrationJobId){
        String MigrationJobName="jiangliutest";
        /*Source Endpoint*/
        String SourceEndpoint_InstanceId="rm-bp185gso372vbd1l8";
        String SourceEndpoint_InstanceType="rds";
        Boolean MigrationMode_SubscriptionDataTypeDML=true;
        Boolean MigrationMode_SubscriptionDataTypeDDL=true;        
        String MigrationObjects="[{\"DBName\":\"jiangliutest\","
                + "\"TableIncludes\":[{\"TableName\":\"t1\"}]}]";
        ConfigureSubscriptionInstanceRequest request = new ConfigureSubscriptionInstanceRequest();
        request.setMigrationJobId(MigrationJobId);
        request.setMigrationJobName(MigrationJobName);
        request.setSubscriptionInstanceId(jobId);
        request.setSubscriptionDataTypeDDL(MigrationMode_SubscriptionDataTypeDDL);
        request.setSubscriptionDataTypeDML(MigrationMode_SubscriptionDataTypeDML);
        request.setSourceEndpointInstanceType(SourceEndpoint_InstanceType);
        request.setSourceEndpointInstanceID(SourceEndpoint_InstanceId);
        request.setMigrationObject(MigrationObjects);
        try {
            ConfigureSubscriptionInstanceResponse response = client.getAcsResponse(request);
            System.out.println("Configure "+ MigrationJobId+ " Succeed");
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println("Configure "+MigrationJobId + " Failed!");
            System.out.println(e.toString());
        }    
    }

展开
收起
云栖大讲堂 2017-10-31 16:21:07 1531 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
基于RocketMQ Connect 构建全新数据流转处理平 立即下载
ACK集群类型选择最佳实践 立即下载
低代码开发师(初级)实战教程 立即下载