Inheritance: AmqpObject
示例#1
0
        public DuplexAmqpLink(AmqpSession session, AmqpLinkSettings settings)
            : base("duplex")
        {
            AmqpTrace.Provider.AmqpLogOperationInformational(this, TraceOperation.Create, "Create");

            var senderSettings = new AmqpLinkSettings
            {
                Role = false,
                LinkName = settings.LinkName + ":out",
                SettleType = settings.SettleType,
                Source = new Source(),
                TotalLinkCredit = settings.TotalLinkCredit,
                AutoSendFlow = settings.AutoSendFlow,
                Target = settings.Target,
                Properties = settings.Properties
            };
            this.sender = new SendingAmqpLink(session, senderSettings);

            var receiverSettings = new AmqpLinkSettings
            {
                Role = true,
                LinkName = settings.LinkName + ":in",
                SettleType = settings.SettleType,
                Source = settings.Source,
                TotalLinkCredit = settings.TotalLinkCredit,
                AutoSendFlow = settings.AutoSendFlow,
                Target = new Target(),
                Properties = settings.Properties
            };
            this.receiver = new ReceivingAmqpLink(session, receiverSettings);
            this.receiver.SetTotalLinkCredit(receiverSettings.TotalLinkCredit, true); // WHY set both here AND on settings? Follow up with Xin.

            this.sender.SafeAddClosed(this.OnLinkClosed);
            this.receiver.SafeAddClosed(this.OnLinkClosed);
        }
        public IotHubTokenRefresher(AmqpSession amqpSession, IotHubConnectionString connectionString, string audience)
        {
            if (amqpSession == null)
            {
                throw new ArgumentNullException("amqpSession");
            }

            this.amqpSession = amqpSession;
            this.connectionString = connectionString;
            this.audience = audience;
        }
示例#3
0
 public IncomingSessionChannel(AmqpSession session)
     : base(session)
 {
     this.incomingWindow = session.settings.IncomingWindow();
     this.flowThreshold = this.incomingWindow * 2 / 3;
     this.IsReceiver = true;
 }
 public ReceivingAmqpLink(AmqpSession session, AmqpLinkSettings settings) :
     base("receiver", session, settings)
 {
 }
示例#5
0
 public SessionChannel(AmqpSession session)
 {
     this.session        = session;
     this.nextDeliveryId = session.settings.InitialDeliveryId;
     this.syncRoot       = new object();
 }
示例#6
0
 /// <summary>
 /// Called when a channel number is not found in a connection or a link handle is not found in a session.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="session">Null if it is for a session channel, or the session of the missing link handle.</param>
 /// <param name="type">Type of the handle ("session" or "link").</param>
 /// <param name="handle">The session channel or the link handle.</param>
 public virtual void AmqpMissingHandle(AmqpConnection connection, AmqpSession session, string type, uint handle)
 {
 }
 void CloseConnection(AmqpSession amqpSession)
 {
     // Closing the connection also closes any sessions.
     amqpSession.Connection.SafeClose();
     this.iotHubTokenRefresher.Cancel();
 }
示例#8
0
 public OutgoingSessionChannel(AmqpSession session)
     : base(session)
 {
     this.nextOutgoingId = session.settings.NextOutgoingId.Value;
     this.outgoingWindow = session.settings.OutgoingWindow.Value;
     this.IsReceiver = false;
 }
 public RequestResponseAmqpLink(string type, AmqpSession session, string address, Fields properties)
     : this(type, null, session, address, properties)
 {
 }
示例#10
0
        public void AddSession(AmqpSession session, ushort? channel)
        {
            session.Closed += onSessionClosed;
            lock (this.ThisLock)
            {
                session.LocalChannel = (ushort)this.sessionsByLocalHandle.Add(session);
                if (channel != null)
                {
                    this.sessionsByRemoteHandle.Add(channel.Value, session);
                }
            }

            AmqpTrace.Provider.AmqpAddSession(this, session, session.LocalChannel, channel ?? 0);
        }
示例#11
0
 /// <summary>
 /// Called when a link is being added to a session.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="link">The lin.</param>
 /// <param name="localHandle">Local handle of the link.</param>
 /// <param name="remoteHandle">Remote handle of the link.</param>
 /// <param name="linkName">Name of the link.</param>
 /// <param name="role">Role of the link.</param>
 /// <param name="source"><see cref="Source"/> of the link.</param>
 /// <param name="target"><see cref="Target"/> of the link.</param>
 public virtual void AmqpAttachLink(AmqpSession session, AmqpLink link, uint localHandle, uint remoteHandle, string linkName, string role, object source, object target)
 {
 }
示例#12
0
 /// <summary>
 /// Called when a session is being added to a connection.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="session">The session.</param>
 /// <param name="localChannel">Local channel number of the session.</param>
 /// <param name="remoteChannel">Remote channel number of the session.</param>
 public virtual void AmqpAddSession(AmqpConnection connection, AmqpSession session, ushort localChannel, ushort remoteChannel)
 {
 }
示例#13
0
 /// <summary>
 /// Called when a session window is 0 when a tranfer is sent or received.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="nextId">Next transfer id.</param>
 public virtual void AmqpSessionWindowClosed(AmqpSession session, int nextId)
 {
 }
示例#14
0
 /// <summary>
 /// Called when a link is being removed from a session.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="link">The link.</param>
 /// <param name="localHandle">Local handle of the link.</param>
 /// <param name="remoteHandle">Remote handle of the link.</param>
 /// <param name="linkName">Name of the link.</param>
 public virtual void AmqpRemoveLink(AmqpSession session, object link, uint localHandle, uint remoteHandle, string linkName)
 {
 }
示例#15
0
 public ErrorLink(AmqpSession session, AmqpLinkSettings settings)
     : base("error-link", session, settings)
 {
     settings.Properties = null;
 }
示例#16
0
 public SessionChannel(AmqpSession session)
 {
     this.session = session;
     this.nextDeliveryId = session.settings.InitialDeliveryId;
     this.syncRoot = new object();
     if (session.settings.DispositionInterval > TimeSpan.Zero)
     {
         this.dispositionTimer = new Timer(s => DispositionTimerCallback(s), this, Timeout.Infinite, Timeout.Infinite);
     }
 }
 public RequestResponseAmqpLink(string type, string name, AmqpSession session, string address)
     : this(type, name, session, address, null)
 {
 }
示例#18
0
        public AmqpLink CreateLink(AmqpSession session, AmqpLinkSettings settings)
        {
            bool isReceiver = settings.Role.Value;
            AmqpLink link;
            if (isReceiver)
            {
                if (settings.Target is Target && ((Target)settings.Target).Dynamic())
                {
                    string name = string.Format("$dynamic.{0}", Interlocked.Increment(ref this.dynamicId));
                    this.queues.Add(name, new TestQueue(this));
                    ((Target)settings.Target).Address = name;
                }

                link = new ReceivingAmqpLink(session, settings);
            }
            else
            {
                if (((Source)settings.Source).Dynamic())
                {
                    string name = string.Format("$dynamic.{0}", Interlocked.Increment(ref this.dynamicId));
                    this.queues.Add(name, new TestQueue(this));
                    ((Source)settings.Source).Address = name;
                }

                link = new SendingAmqpLink(session, settings);
            }

            return link;
        }
示例#19
0
        int references; // make sure no frames are sent after close

        /// <summary>
        /// Initializes the link object.
        /// </summary>
        /// <param name="session">The session in which the link is created.</param>
        /// <param name="linkSettings">The link settings.</param>
        protected AmqpLink(AmqpSession session, AmqpLinkSettings linkSettings)
            : this("link", session, linkSettings)
        {
        }
 void CloseConnection(AmqpSession amqpSession)
 {
     // Closing the connection also closes any sessions.
     amqpSession.Connection.SafeClose();
 }
示例#21
0
        int references; // make sure no frames are sent after close

        protected AmqpLink(AmqpSession session, AmqpLinkSettings linkSettings)
            : this("link", session, linkSettings)
        {
            this.inflightDeliveries = new SerializedWorker <Delivery>(this);
        }
示例#22
0
 public ErrorLink(AmqpSession session, AmqpLinkSettings settings)
     : base("error-link", session, settings)
 {
     settings.Properties = null;
 }
示例#23
0
            protected override IEnumerator <AsyncStep> GetAsyncSteps()
            {
                string address = CbsConstants.CbsAddress;

                while (this.RemainingTime() > TimeSpan.Zero)
                {
                    try
                    {
                        AmqpSessionSettings sessionSettings = new AmqpSessionSettings()
                        {
                            Properties = new Fields()
                        };
                        this.session = new AmqpSession(this.connection, sessionSettings, this);
                        connection.AddSession(session, null);
                    }
                    catch (InvalidOperationException exception)
                    {
                        this.Complete(exception);
                        yield break;
                    }

                    yield return(this.CallAsync(
                                     (thisPtr, t, c, s) => thisPtr.session.BeginOpen(t, c, s),
                                     (thisPtr, r) => thisPtr.session.EndOpen(r),
                                     ExceptionPolicy.Continue));

                    Exception lastException = this.LastAsyncStepException;
                    if (lastException != null)
                    {
                        AmqpTrace.Provider.AmqpOpenEntityFailed(this.connection, this.session, string.Empty, address, lastException.Message);
                        this.session.Abort();
                        this.Complete(lastException);
                        yield break;
                    }

                    AmqpLinkSettings settings = new AmqpLinkSettings();
                    settings.AddProperty(CbsConstants.TimeoutName, (uint)this.RemainingTime().TotalMilliseconds);
                    settings.Target = new Target()
                    {
                        Address = address
                    };
                    settings.Source = new Source()
                    {
                        Address = address
                    };
                    settings.InitialDeliveryCount = 0;
                    settings.TotalLinkCredit      = 50;
                    settings.AutoSendFlow         = true;
                    settings.SettleType           = SettleMode.SettleOnSend;

                    this.Link = new RequestResponseAmqpLink(this.session, settings);
                    yield return(this.CallAsync(
                                     (thisPtr, t, c, s) => thisPtr.Link.BeginOpen(t, c, s),
                                     (thisPtr, r) => thisPtr.Link.EndOpen(r),
                                     ExceptionPolicy.Continue));

                    lastException = this.LastAsyncStepException;
                    if (lastException != null)
                    {
                        AmqpTrace.Provider.AmqpOpenEntityFailed(this.connection, this.Link, this.Link.Name, address, lastException.Message);
                        this.session.SafeClose();
                        this.Link = null;
                        this.Complete(lastException);
                        yield break;
                    }

                    AmqpTrace.Provider.AmqpOpenEntitySucceeded(this.connection, this.Link, this.Link.Name, address);
                    yield break;
                }

                if (this.session != null)
                {
                    this.session.SafeClose();
                }

                this.Complete(new TimeoutException(AmqpResources.GetString(AmqpResources.AmqpTimeout, this.OriginalTimeout, address)));
            }