Пример #1
0
        private IModel GetChannel(ConectionType type)
        {
            switch (type)
            {
            case ConectionType.Publish:
                if (_publishChannel != null && _publishChannel.IsOpen)
                {
                    return(_publishChannel);
                }
                _publishChannel = GetConnection(type).CreateModel();
                _publishChannel.ConfirmSelect();
                return(_publishChannel);

            case ConectionType.Consume:
                if (_consumeChannel != null && _consumeChannel.IsOpen)
                {
                    return(_consumeChannel);
                }
                _consumeChannel = GetConnection(type).CreateModel();
                _consumeChannel.BasicQos(0, 1, false);
                return(_consumeChannel);

            default:
                throw new ArgumentException(string.Format(ErrorMessages.MustBeInformed, "The connection type"));
            }
        }
Пример #2
0
        private IConnection GetConnection(ConectionType type)
        {
            switch (type)
            {
            case ConectionType.Publish:
                if (_publishConnection != null && _publishConnection.IsOpen)
                {
                    return(_publishConnection);
                }
                try
                {
                    _publishConnection = GetConnectionFactory().CreateConnection();
                    return(_publishConnection);
                }
                catch (BrokerUnreachableException e)
                {
                    throw new InvalidOperationException(string.Format(ErrorMessages.UnableToConnect, "RabbitMQ"), e);
                }

            case ConectionType.Consume:
                if (_consumeConnection != null && _consumeConnection.IsOpen)
                {
                    return(_consumeConnection);
                }
                try
                {
                    _consumeConnection = GetConnectionFactory().CreateConnection();
                    return(_consumeConnection);
                }
                catch (BrokerUnreachableException e)
                {
                    throw new InvalidOperationException(string.Format(ErrorMessages.UnableToConnect, "RabbitMQ"), e);
                }

            default:
                throw new ArgumentException(string.Format(ErrorMessages.MustBeInformed, "The connection type"));
            }
        }
Пример #3
0
 private void GetNameOrganization(ConectionType type)
 {
     _conexion.nameOrganization = txtURL.Text.Substring((int)type, txtURL.Text.IndexOf('.') - (int)type);
 }