예제 #1
0
 internal RabbitMQChannelZero(RabbitMQConnectionBuilder builder, RabbitMQProtocol protocol) : base(protocol)
 {
     MainInfo        = builder.MainInfo;
     ClientInfo      = builder.ClientInfo;
     _connectionInfo = builder.ConnInfo;
     _channelId      = 0;
     _isOpen         = false;
 }
예제 #2
0
 internal RabbitMQDefaultChannel(RabbitMQProtocol protocol, ushort id, Action <ushort> closeCallback) : base(protocol)
 {
     _channelId             = id;
     _protocol              = protocol;
     _isOpen                = false;
     _managerCloseCallback  = closeCallback;
     _exchangeMethodHandler = new ExchangeHandler(_channelId, _protocol);
     _queueMethodHandler    = new QueueHandler(_channelId, _protocol);
     _basicHandler          = new BasicHandler(_channelId, _protocol);
 }
        public async Task StartAsync()
        {
            _context = await _client.ConnectAsync(RemoteEndPoint, _cts.Token).ConfigureAwait(false);

            _protocol    = new RabbitMQProtocol(_context);
            Channel0     = new RabbitMQChannelZero(_builder, _protocol);
            _readingTask = StartReading();
            bool openned = await Channel0.TryOpenChannelAsync().ConfigureAwait(false);

            if (!openned)
            {
                _context.Abort();
                _cts.Cancel();
                return;
            }
        }
예제 #4
0
        /// <summary>
        ///     Create a connection factory given the provided connection parameters
        /// </summary>
        /// <param name="protocol"><c>RabbitMQProtocol.AMQP</c> or the SSL-enabled <c>RabbitMQProtocol.AMQPS</c></param>
        /// <param name="host">The RabbitMQ endpoint</param>
        /// <param name="vhost">The virtual host to connect to</param>
        /// <param name="port">The endpoint TCP port</param>
        /// <param name="cert">
        ///     The certificate to use for SSL handshake. Can also be used for external authentication if no
        ///     username/password provided.
        /// </param>
        /// <param name="container">The AutoFac container for MediatR handler registration</param>
        /// <param name="username">The connection username (not required if using external authentication)</param>
        /// <param name="password">The connection password (not required if using external authentication)</param>
        public RabbitMQConnectionFactory(RabbitMQProtocol protocol, string host, string vhost, int port, X509Certificate2 cert, IContainer container,
                                         string username = null, string password = null)
        {
            var       scheme = "amqp";
            Uri       uri;
            SslOption sslOption = null;

            IAuthMechanismFactory[] authMechanisms = { new PlainMechanismFactory() };
            switch (protocol)
            {
            case RabbitMQProtocol.AMQPS:
                scheme         = "amqps";
                authMechanisms = username == null && password == null
                        ? new IAuthMechanismFactory[] { new ExternalMechanismFactory() }
                        : authMechanisms;
                // it is a bit of an assumption that the SSL certificate name match the hostname, but it usually should
                sslOption = new SslOption
                {
                    Enabled                = true,
                    Certs                  = new X509Certificate2Collection(new[] { cert }),
                    ServerName             = host,
                    AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateChainErrors
                };
                break;
            }

            uri = new Uri($"{scheme}://{host}:{port}/");
            _connectionFactory = new ConnectionFactory
            {
                Uri         = uri,
                HostName    = host,
                VirtualHost = vhost,
                UserName    = username,
                Password    = password,
                Port        = port,
                Ssl         = sslOption ?? new SslOption {
                    Enabled = false
                },
                AuthMechanisms         = authMechanisms,
                DispatchConsumersAsync = true
            };
            ServiceContainer = container;
        }
 internal RabbitMQConsumer(string consumerTag, RabbitMQProtocol protocol, ushort channelId)
     : base(consumerTag, channelId, protocol)
 {
     _reader          = new BodyFrameChunkedReader();
     _deliverPosition = 0;
 }
예제 #6
0
 public ChannelReaderWriter(RabbitMQProtocol protocol)
 {
     _protocol = protocol;
 }
예제 #7
0
 public QueueReaderWriter(ushort channelId, RabbitMQProtocol protocol)
 {
     _protocol = protocol;
     ChannelId = channelId;
 }
예제 #8
0
 public ExchangeHandler(ushort channelId, RabbitMQProtocol protocol) : base(channelId, protocol)
 {
     _exchanges = new Dictionary <string, ExchangeInfo>();
     _semafore  = new SemaphoreSlim(1);
 }
 internal ConsumerBase(string tag, ushort channel, RabbitMQProtocol protocol)
 {
     ConsumerTag = tag;
     ChannelId   = channel;
     _protocol   = protocol;
 }
 public ExchangeReaderWriter(ushort channelId, RabbitMQProtocol protocol)
 {
     _channelId = channelId;
     _protocol  = protocol;
 }
 public ConnectionReaderWriter(RabbitMQProtocol protocol)
 {
     _protocol = protocol;
 }
예제 #12
0
 public RabbitMQDeliver(DeliverInfo info, ushort channelId, RabbitMQProtocol protocol)
 {
     Info       = info;
     _protocol  = protocol;
     _channelId = channelId;
 }
예제 #13
0
 public BasicHandler(ushort channelId, RabbitMQProtocol protocol) : base(channelId, protocol)
 {
     _consumers = new Dictionary <string, ConsumerBase>();
     _semaphore = new SemaphoreSlim(1);
 }
 internal RabbitMQChunkedConsumer(string consumerTag, RabbitMQProtocol protocol, ushort channelid)
     : base(consumerTag, channelid, protocol)
 {
     _reader = new BodyFrameChunkedReader();
 }
 internal RabbitMQPublisher(ushort channelId, RabbitMQProtocol protocol)
 {
     _channelId = channelId;
     _protocol  = protocol;
 }
 public BasicReaderWriter(ushort channelId, RabbitMQProtocol protocol)
 {
     _channelId          = channelId;
     _protocol           = protocol;
     _basicDeliverReader = new BasicDeliverReader();
 }