SDK订阅配置流程:
- SDK数据订阅原理介绍
- 订阅SDK兼容DEMO
- 组件注册
- 订阅服务启动配置&管理
SDK发布原理介绍
订阅SDK兼容DEMO
订阅SDK Demo
- ZcbusClientServiceDemo.java
package com.zcbus.Service;
import com.zcbus.common.BusClientCmd;
import com.zcbus.common.BusDataVector;
import com.zcbus.common.BusJsonConverter;
import com.zcbus.common.BusServer;
import com.zcbus.common.ZcbusTime;
public class ZcbusClientServiceDemo extends BusClientCmd {
public void close() {
}
public void processBusdata(byte[] busData, int dataLength) throws Exception {
BusDataVector bdVector = new BusDataVector();
int offset = 0;
while (offset < dataLength) {
int len = bdVector.deserialize(busData, offset, dataLength);
if (len <= 0) {
throw new Exception(String.format("bus data offset %d, length is %d", offset, len));
}
byte bt[]=bdVector.getCustomData();
System.err.println("optype :"+bdVector.getOpType());
System.err.println("trans DATA :"+new String(bt));
BusJsonConverter busJsonConverter=new BusJsonConverter();
busJsonConverter.setLoaderTime(ZcbusTime.getCurrentTime());
busJsonConverter.setSendType("data");
busJsonConverter.setBatchCode("zcuscode");
StringBuilder stringBuilder=new StringBuilder();
busJsonConverter.convetJson(bdVector, stringBuilder);
System.err.println(stringBuilder.toString());
// bdVector.dump();
offset += len;
}
System.out.println(" customerID: " + getCustomerID());
System.out.println(" controlID: " + getControlID());
System.out.println(" tableID: " + getTableID());
System.out.println(" dbName: " + getDbName());
System.out.println(" tableName: " + getTableName());
System.out.println(" tableName: " + getObjectID());
System.out.println(" tableName: " + getThreadId());
System.out.println("data length: " + dataLength);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
for (int i = 0; i < args.length; i++) {
if (0 == args[i].compareTo("-h")) {
System.out.println(
"Usage: \n" + " -h help\n" + " -log_level 2 log_level\n"
+ " -max_thread 128 specify max threads of client service, default 512\n"
+ " -customer_id 10058 specify customer id of client service, use for port\n");
return;
} else if (0 == args[i].compareTo("-customer_id")) {
customer_id = Integer.parseInt(args[++i]);
}else if (0 == args[i].compareTo("-log_level")) {
logLevel = Integer.parseInt(args[++i]);
}else if (0 == args[i].compareTo("-max_thread")) {
max_threads = Integer.parseInt(args[++i]);
}else {
ZcbusLog.error("unkown options: " + args[i]);
return;
}
}
if (customer_id <= 0) {
ZcbusLog.error("cusomter_id not set");
return;
}
try {
ZcbusEnv.init();
String logFile = ZcbusEnv.getZcbusLogPath() + "/log.db_service." + customer_id;
ZcbusLog.open(logFile);
ZcbusLog.setLevel(logLevel);
String workDirectory = ZcbusEnv.getZcbusCachePath() + "/db_service" + customer_id;
ZcbusEnv.setWorkDirectory(workDirectory);
ZcbusLog.print(2, "make workDirectory: " + workDirectory);
ZcbusEnv.createDir(workDirectory);
if (max_threads < 1)
max_threads = 512;
BusServer busServer = new BusServer(customer_id);
BusServer.registClientCmdClass(ZcbusClientServiceDemo.class);
busServer.run();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
组件注册
INSERT INTO `bus_service_type_model` (`usage`, `db_type`, `use_way`, `service_subtype`, `program_name`, `updatetime`) VALUES ('1', 'client', '1', 'etl', 'ZcbusEtlServiceDemo.jar', '2022-12-11 15:41:07');
- 目前手工将开发的SendSdkDemo.jar包上传到容器下/usr/local/zcbus/jar目录下
文档更新时间: 2022-12-14 18:06 作者:阿力