support rabbitmq port by config (#3236)

This commit is contained in:
16075140
2021-04-16 22:07:12 +08:00
committed by GitHub
parent f66baeabf1
commit 25feab4af8

View File

@@ -91,7 +91,15 @@ public class CanalRabbitMQConsumer implements CanalMsgConsumer {
factory.setUsername(username);
factory.setPassword(password);
}
factory.setHost(nameServer);
//解析出端口 modified by 16075140
if (nameServer != null && nameServer.contains(":")) {
String[] serverHostAndPort = nameServer.split(":");
factory.setHost(serverHostAndPort[0]);
factory.setPort(Integer.parseInt(serverHostAndPort[1]));
} else {
factory.setHost(nameServer);
}
factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(5000);
factory.setVirtualHost(vhost);