mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
通过groupId过滤对应的adapter配置
This commit is contained in:
@@ -15,6 +15,7 @@ public class Dml implements Serializable {
|
||||
private static final long serialVersionUID = 2611556444074013268L;
|
||||
|
||||
private String destination; // 对应canal的实例或者MQ的topic
|
||||
private String groupId; // 对应mq的group id
|
||||
private String database; // 数据库或schema
|
||||
private String table; // 表名
|
||||
private List<String> pkNames;
|
||||
@@ -36,6 +37,14 @@ public class Dml implements Serializable {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.alibaba.otter.canal.protocol.Message;
|
||||
*/
|
||||
public class MessageUtil {
|
||||
|
||||
public static List<Dml> parse4Dml(String destination, Message message) {
|
||||
public static List<Dml> parse4Dml(String destination, String groupId, Message message) {
|
||||
if (message == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public class MessageUtil {
|
||||
|
||||
final Dml dml = new Dml();
|
||||
dml.setDestination(destination);
|
||||
dml.setGroupId(groupId);
|
||||
dml.setDatabase(entry.getHeader().getSchemaName());
|
||||
dml.setTable(entry.getHeader().getTableName());
|
||||
dml.setType(eventType.toString());
|
||||
@@ -118,10 +119,10 @@ public class MessageUtil {
|
||||
return dmls;
|
||||
}
|
||||
|
||||
public static List<Dml> flatMessage2Dml(String destination, List<FlatMessage> flatMessages) {
|
||||
public static List<Dml> flatMessage2Dml(String destination, String groupId, List<FlatMessage> flatMessages) {
|
||||
List<Dml> dmls = new ArrayList<Dml>(flatMessages.size());
|
||||
for (FlatMessage flatMessage : flatMessages) {
|
||||
Dml dml = flatMessage2Dml(destination, flatMessage);
|
||||
Dml dml = flatMessage2Dml(destination, groupId, flatMessage);
|
||||
if (dml != null) {
|
||||
dmls.add(dml);
|
||||
}
|
||||
@@ -130,12 +131,13 @@ public class MessageUtil {
|
||||
return dmls;
|
||||
}
|
||||
|
||||
public static Dml flatMessage2Dml(String destination, FlatMessage flatMessage) {
|
||||
public static Dml flatMessage2Dml(String destination, String groupId, FlatMessage flatMessage) {
|
||||
if (flatMessage == null) {
|
||||
return null;
|
||||
}
|
||||
Dml dml = new Dml();
|
||||
dml.setDestination(destination);
|
||||
dml.setGroupId(groupId);
|
||||
dml.setDatabase(flatMessage.getDatabase());
|
||||
dml.setTable(flatMessage.getTable());
|
||||
dml.setPkNames(flatMessage.getPkNames());
|
||||
|
||||
Reference in New Issue
Block a user