Beispiel #1
0
        public IModel CreateChannel(IMessageConnector connector)
        {
            IModel channel = _connection.CreateModel();

            channel.ModelShutdown += (sender, args) =>
            {
                _logger.LogInformation($"Channel shutdown for connector Id: {connector.Id} - type {connector.GetType().Name} - reason id: {args.ReplyCode} - Text: {args.ReplyText} - Initiator: {args.Initiator}");
                RegisteredConnectors.TryRemove(connector.Id, out _);
            };

            RegisterConnector(connector, channel);

            return(channel);
        }
Beispiel #2
0
        internal IModel GetAssociatedChannel(IMessageConnector connector)
        {
            IModel channel = null;

            if (IsConnect && RegisteredConnectors.TryGetValue(connector.Id, out channel))
            {
                if (channel == null || channel.IsOpen)
                {
                    RegisteredConnectors.TryRemove(connector.Id, out _);
                }
            }

            return(channel);
        }