mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
mq模式下adapter配置增加groupId属性对应
This commit is contained in:
@@ -86,8 +86,9 @@ public class RdbAdapter implements OuterAdapter {
|
||||
String configName = entry.getKey();
|
||||
MappingConfig mappingConfig = entry.getValue();
|
||||
if (!mappingConfig.getDbMapping().getMirrorDb()) {
|
||||
String key = StringUtils.trimToEmpty(mappingConfig.getDestination()) + "."
|
||||
+ mappingConfig.getDbMapping().getDatabase() + "."
|
||||
String key = StringUtils.trimToEmpty(mappingConfig.getDestination()) + "-"
|
||||
+ StringUtils.trimToEmpty(mappingConfig.getGroupId()) + "_"
|
||||
+ mappingConfig.getDbMapping().getDatabase() + "-"
|
||||
+ mappingConfig.getDbMapping().getTable();
|
||||
Map<String, MappingConfig> configMap = mappingConfigCache.computeIfAbsent(key,
|
||||
k1 -> new ConcurrentHashMap<>());
|
||||
|
||||
@@ -147,9 +147,11 @@ public class RdbSyncService {
|
||||
} else {
|
||||
// DML
|
||||
String destination = StringUtils.trimToEmpty(dml.getDestination());
|
||||
String groupId = StringUtils.trimToEmpty(dml.getGroupId());
|
||||
String database = dml.getDatabase();
|
||||
String table = dml.getTable();
|
||||
Map<String, MappingConfig> configMap = mappingConfig.get(destination + "." + database + "." + table);
|
||||
Map<String, MappingConfig> configMap = mappingConfig
|
||||
.get(destination + "-" + groupId + "_" + database + "-" + table);
|
||||
|
||||
if (configMap == null) {
|
||||
return false;
|
||||
@@ -169,7 +171,6 @@ public class RdbSyncService {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean executed = false;
|
||||
for (MappingConfig config : configs) {
|
||||
if (config.getConcurrent()) {
|
||||
List<SingleDml> singleDmls = SingleDml.dml2SingleDmls(dml);
|
||||
@@ -186,9 +187,8 @@ public class RdbSyncService {
|
||||
dmlsPartition[hash].add(syncItem);
|
||||
});
|
||||
}
|
||||
executed = true;
|
||||
}
|
||||
return executed;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
dataSourceKey: defaultDS
|
||||
destination: example
|
||||
outerAdapterKey: oracle1
|
||||
groupId: g1
|
||||
outerAdapterKey: mysql1
|
||||
concurrent: true
|
||||
dbMapping:
|
||||
database: mytest
|
||||
table: user
|
||||
targetTable: mytest.tb_user
|
||||
targetTable: mytest2.user
|
||||
targetPk:
|
||||
id: id
|
||||
# mapAll: true
|
||||
@@ -17,9 +18,10 @@ dbMapping:
|
||||
test1:
|
||||
|
||||
|
||||
# Mirror schema synchronize config
|
||||
## Mirror schema synchronize config
|
||||
#dataSourceKey: defaultDS
|
||||
#destination: example
|
||||
#groupId: g1
|
||||
#outerAdapterKey: mysql1
|
||||
#concurrent: true
|
||||
#dbMapping:
|
||||
|
||||
Reference in New Issue
Block a user