1. 程式人生 > >.Net Core連接RabbitMQ集群

.Net Core連接RabbitMQ集群

pass 連接 cti enable rabbit chan tom span recovery

 1             var connectionFactory = new ConnectionFactory()
 2             {
 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

.Net Core連接RabbitMQ集群