コード例 #1
0
        public async Task CloseAsync(CancellationToken cancellationToken)
        {
            AmqpConnection connection = AmqpConnection;

            if (connection != null)
            {
                await connection.CloseAsync(cancellationToken).ConfigureAwait(false);
            }
        }
コード例 #2
0
        public async Task CloseAsync(TimeSpan timeout)
        {
            AmqpConnection connection = AmqpConnection;

            if (connection != null)
            {
                await connection.CloseAsync(timeout).ConfigureAwait(false);
            }
        }
コード例 #3
0
            protected override IEnumerator <IteratorTask <object> .TaskStep> GetTasks()
            {
                if (this.relay.tokenRenewer != null)
                {
                    this.relay.tokenRenewer.Close();
                }
                AmqpConnection amqpConnection = this.relay.connection;

                if (amqpConnection != null)
                {
                    if (this.aborting)
                    {
                        amqpConnection.SafeClose();
                    }
                    else
                    {
                        yield return(base.CallTask(amqpConnection.CloseAsync(this.timeout), IteratorTask <TResult> .ExceptionPolicy.Transfer));
                    }
                }
                this.relay.State = AmqpObjectState.End;
            }
コード例 #4
0
        async Task RunClientAsync(string address)
        {
            AmqpConnectionFactory factory = new AmqpConnectionFactory();

            factory.Settings.TransportProviders.Add(
                new TlsTransportProvider(
                    new TlsTransportSettings()
            {
                CertificateValidationCallback = (a, b, c, d) => true
            },
                    AmqpVersion.V100));

            AmqpConnection connection = await factory.OpenConnectionAsync(address);

            AmqpSession session = connection.CreateSession(new AmqpSessionSettings());
            await session.OpenAsync(TimeSpan.FromSeconds(20));

            SendingAmqpLink sLink = new SendingAmqpLink(session, AmqpUtils.GetLinkSettings(true, queue, SettleMode.SettleOnSend));
            await sLink.OpenAsync(TimeSpan.FromSeconds(20));

            AmqpMessage message = AmqpMessage.Create(new AmqpValue()
            {
                Value = "AmqpConnectionFactoryTest"
            });
            Outcome outcome = await sLink.SendMessageAsync(message, EmptyBinary, NullBinary, TimeSpan.FromSeconds(10));

            Assert.Equal(Accepted.Code, outcome.DescriptorCode);

            ReceivingAmqpLink rLink = new ReceivingAmqpLink(session, AmqpUtils.GetLinkSettings(false, queue, SettleMode.SettleOnDispose, 10));
            await rLink.OpenAsync(TimeSpan.FromSeconds(20));

            var receivedMessage = await rLink.ReceiveMessageAsync(TimeSpan.FromSeconds(20));

            Assert.NotNull(receivedMessage);
            outcome = await rLink.DisposeMessageAsync(receivedMessage.DeliveryTag, new Accepted(), false, TimeSpan.FromSeconds(20));

            Assert.Equal(Accepted.Code, outcome.DescriptorCode);

            await connection.CloseAsync(TimeSpan.FromSeconds(20));
        }