//TODO:判断连接失败 public static WorkQueueProducer createInstance(IRabbitMqFactory factory, string queueName) { WorkQueueProducer instance = new WorkQueueProducer(); instance.mConnection = factory.CreateConnection(); instance.mChannel = instance.mConnection.CreateChannel(); instance.mQueueName = queueName; return(instance); }
//TODO:判断连接失败 public static WorkQueueConsumer createInstance(IRabbitMqFactory factory, string queueName) { WorkQueueConsumer instance = new WorkQueueConsumer(); instance.mConnection = factory.CreateConnection(); instance.mChannel = instance.mConnection.CreateChannel(); instance.mQueueName = queueName; instance.mChannel.QueueDeclare(queue: instance.mQueueName, durable: true, exclusive: false, autoDelete: false, arguments: null); instance.mConsumer = instance.mChannel.GetEventingBasicConsumer(); return(instance); }