1 var connectionFactory = new ConnectionFactory()
3 //HostName = "192.168.205.128", 集群不在此处声明
4 UserName = "guest",
5 Password = "guest",
6 AutomaticRecoveryEnabled = true,//如果connection挂掉是否重新连接
7 TopologyRecoveryEnabled = true//连接恢复后,连接的交换机,队列等是否一同恢复
8 }; //创建连接工厂
9 var connection = connectionFactory.CreateConnection(new string[] {
10 "192.168.23.149",
11 "192.168.23.144",
12 "192.168.23.143"
13 }); //创建connection
14 var channel = connection.CreateModel(); //创建channel