Пример #1
0
        void OnAcceptTransport(TransportListener transportListener, TransportAsyncCallbackArgs args)
        {
            if (args.Exception != null)
            {
                Events.AcceptTransportInputError(args.Exception);
                ExceptionDispatchInfo.Capture(args.Exception).Throw();
            }

            AmqpConnection connection = null;

            try
            {
                connection = this.amqpSettings.RuntimeProvider.CreateConnection(
                    args.Transport,
                    (ProtocolHeader)args.UserToken,
                    false,
                    this.amqpSettings.Clone(),
                    this.connectionSettings.Clone());

                // Open the connection async but don't block waiting on it.
                this.OpenAmqpConnectionAsync(connection, AmqpConstants.DefaultTimeout)
                .ContinueWith(
                    task =>
                {
                    if (task.Exception != null)
                    {
                        Events.OpenConnectionError(task.Exception);
                    }
                },
                    TaskContinuationOptions.OnlyOnFaulted);
            }
            catch (Exception ex) when(ex.IsFatal() == false)
            {
                Events.AcceptTransportError(ex);
                connection?.SafeClose(ex);
            }
        }