Exemplo n.º 1
0
 private static void Conn(RabbitSenderOption option)
 {
     if (option == null)
     {
         return;
     }
     if (string.IsNullOrEmpty(option.RoutingKey))
     {
         option.RoutingKey = option.QueueName;
     }
     if (_channel == null)
     {
         lock (Object)
         {
             if (_channel == null)
             {
                 try
                 {
                     _channel = RabbitConfig.Connection.CreateModel();
                 }
                 catch (Exception exception)
                 {
                     RabbitConfig.ProcessException(exception);
                     _channel = RabbitConfig.Connection.CreateModel();
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 private void Conn(string channelName)
 {
     if (connection.Where(a => a.Key == channelName).Count() == 0)
     {
         lock (_object)
         {
             if (connection.Where(a => a.Key == channelName).Count() == 0)
             {
                 try
                 {
                     _channel = RabbitConfig.Connection.CreateModel();
                     connection.Add(channelName, _channel);
                 }
                 catch (Exception exception)
                 {
                     RabbitConfig.ProcessException(exception);
                     _channel = RabbitConfig.Connection.CreateModel();
                     connection.Add(channelName, _channel);
                 }
             }
         }
     }
 }