예제 #1
0
        private void SetupConnection()
        {
            if (_connection != null && _connection.IsOpen)
            {
                return;
            }

            _connection?.Dispose();

            _connection = _factory.CreateConnection();
            _connection.ConnectionShutdown += _connection_ConnectionShutdown;
            _logger.LogInformation("Connection is ready");
        }
 public void Dispose()
 {
     _channel?.Dispose();
     _channel = null;
     _connection?.Dispose();
     _connection = null;
 }
        /// <summary>
        /// 关闭
        /// </summary>
        public override void Close()
        {
            if (channels.Count > 0)
            {
                foreach (IModel channel in channels)
                {
                    if (channel.IsOpen)
                    {
                        channel.Close();
                        channel.Dispose();
                    }
                }

                channels.Clear();
            }

            if (Status == ConnectionStatusType.OPENED)
            {
                connection.Close();
                connection.Dispose();
            }

            connection = null;

            OnClosed();
        }
        /// <summary>
        /// 执行关闭
        /// </summary>
        /// <returns>事件数据</returns>
        protected override object ExecClose()
        {
            if (channels.Count > 0)
            {
                foreach (IModel channel in channels)
                {
                    if (channel.IsOpen)
                    {
                        channel.Close();
                        channel.Dispose();
                    }
                }

                channels.Clear();
            }

            if (Status == ConnectionStatusType.OPENED)
            {
                connection.Close();
                connection.Dispose();
            }

            connection  = null;
            virtualPath = RabbitConnectionInfo.DEFAULT_VIRTUAL_PATH;

            return(null);
        }
 public void Dispose()
 {
     if (!(_connection is null))
     {
         _connection.Dispose();
         _connection = null;
     }
 }
예제 #6
0
        protected virtual void Dispose(bool isDisposing)
        {
            if (!_isDisposed)
            {
                if (isDisposing)
                {
                    _connection.Dispose();
                }

                _isDisposed = true;
            }
        }
예제 #7
0
        /// <summary>
        /// 执行关闭
        /// </summary>
        /// <returns>事件数据</returns>
        protected override object ExecClose()
        {
            if (channels.Count > 0)
            {
                foreach (IModel channel in channels)
                {
                    if (channel.IsOpen)
                    {
                        channel.Close();
                        channel.Dispose();
                    }
                }

                channels.Clear();
            }

            if (Status == ConnectionStatusType.OPENED)
            {
                connection.Close();
                connection.Dispose();
            }

            return(null);
        }
예제 #8
0
        } // MakeNewConnection

        private void DestroyConnection(ref RmqCl.IConnection connection, ref RmqCl.IModel channel)
        {
            // This method disposes the AMQP-connection-related object

            try
            {
                if (channel != null)
                {
                    if (m_messageConsumer != null)
                    {
                        m_messageConsumer.Received -= MessageReceived;
                    }

                    try
                    {
                        channel.ModelShutdown -= ModelShutdown;
                        channel.Close();
                    }
                    catch { }
                    channel.Dispose();
                    channel = null;
                }

                if (connection != null)
                {
                    try
                    {
                        connection.Close();
                    }
                    catch { }
                    connection.Dispose();
                    connection = null;
                }
            }
            catch {}
        } // DestroyConnection
예제 #9
0
 public void Dispose()
 {
     _connection.Dispose();
 }