Пример #1
0
 protected override bool Run(Func <IModel, bool> fn)
 {
     try
     {
         using (MQConnection connection = MQConnectionManager.GetMqConnection(MQueue.Host.Host, MQueue.Host.Port, MQueue.Host.Username, MQueue.Host.Password))
         {
             using (IModel channel = connection.Connection.CreateModel())
             {
                 return(fn(channel));
             }
         }
     }
     catch (Exception ex)
     {
         logger.LogError(ex, $"消息发送失败,Ip:{MQueue.Host.ToString()}");
         return(false);
     }
 }
Пример #2
0
 public void Dispose()
 {
     MQConnectionManager.RelaceConnection(this, _key);
 }