merge /pull/2373

This commit is contained in:
agapple
2020-02-28 11:46:28 +08:00
parent 523e8b85e6
commit b9a157657f

View File

@@ -51,7 +51,15 @@ public class CanalRabbitMQProducer extends AbstractMQProducer implements CanalMQ
loadRabbitMQProperties(properties); loadRabbitMQProperties(properties);
ConnectionFactory factory = new ConnectionFactory(); ConnectionFactory factory = new ConnectionFactory();
factory.setHost(rabbitMQProperties.getHost()); String servers = rabbitMQProperties.getHost();
if (servers.contains(":")) {
String[] serverHostAndPort = servers.split(":");
factory.setHost(serverHostAndPort[0]);
factory.setPort(Integer.parseInt(serverHostAndPort[1]));
} else {
factory.setHost(servers);
}
if (mqProperties.getAliyunAccessKey().length() > 0 && mqProperties.getAliyunSecretKey().length() > 0 if (mqProperties.getAliyunAccessKey().length() > 0 && mqProperties.getAliyunSecretKey().length() > 0
&& mqProperties.getAliyunUid() > 0) { && mqProperties.getAliyunUid() > 0) {
factory.setCredentialsProvider(new AliyunCredentialsProvider(mqProperties.getAliyunAccessKey(), factory.setCredentialsProvider(new AliyunCredentialsProvider(mqProperties.getAliyunAccessKey(),