Esempio n. 1
0
        protected AmqpLink(AmqpSession session, AmqpLinkSettings linkSettings)
        {
            if (linkSettings == null)
            {
                throw new ArgumentNullException("linkSettings");
            }

            this.Session = session;
            this.settings = linkSettings;
            this.linkCredit = this.settings.TransferLimit;
            this.settings.AutoSendFlow = this.linkCredit > 0;
            this.syncRoot = new object();
            Source source = (Source)this.settings.Source;
            if (source != null)
            {
                this.defaultOutcome = source.DefaultOutcome;
            }

            if (this.defaultOutcome == null)
            {
                this.defaultOutcome = AmqpConstants.ReleasedOutcome;
            }

            this.unsettledMap = new Dictionary<ArraySegment<byte>, Delivery>(ByteArrayComparer.Instance);
            this.pendingDeliveries = new SerializedWorker<Delivery>(this.TrySendDelivery, this.AbortDelivery, false);
            session.AttachLink(this);
        }
Esempio n. 2
0
 protected override AmqpLink CreateLink(AmqpSession session)
 {
     AmqpLinkSettings settings = new AmqpLinkSettings();
     settings.LinkName = Guid.NewGuid().ToString("N");
     settings.Target = new Target() { Address = this.Node };
     settings.Role = false;
     settings.SettleType = SettleMode.SettleOnSend;
     return new SendingAmqpLink(session, settings);
 }
Esempio n. 3
0
                public OpenTerminusAsyncResult(Terminus parent, AsyncCallback callback, object state)
                    : base(callback, state)
                {
                    this.parent = parent;
                    this.onObjectOpen = this.OnObjectOpen;

                    this.parent.container.EnsureConnectionOpen();
                    this.session = this.parent.container.connection.CreateSession(new AmqpSessionSettings());
                    this.link = this.parent.CreateLink(this.session);
                    this.session.BeginOpen(TimeSpan.MaxValue, this.onObjectOpen, this.session);
                    this.link.BeginOpen(TimeSpan.MaxValue, this.onObjectOpen, this.link);
                }
Esempio n. 4
0
 protected abstract AmqpLink CreateLink(AmqpSession session);
Esempio n. 5
0
 protected abstract AmqpLink CreateLink(AmqpSession session);
Esempio n. 6
0
 public SendingAmqpLink(AmqpSession session, AmqpLinkSettings settings)
     : base(session, settings)
 {
 }
Esempio n. 7
0
 public IncomingSessionChannel(AmqpSession session)
     : base(session, session.settings.IncomingBufferSize)
 {
     this.name = session.ToString() + "(in)";
     this.pendingTransfers = new SerializedWorker<Tuple<AmqpLink, Transfer>>(this.OnTransfer, null, false);
     this.incomingWindow = session.settings.IncomingWindow();
     this.flowThreshold = this.incomingWindow == uint.MaxValue ? uint.MaxValue : this.incomingWindow * 2 / 3;
     this.IsReceiver = true;
 }
Esempio n. 8
0
        void AddSession(AmqpSession session, ushort? channel)
        {
            session.Closed += new EventHandler(this.OnSessionClosed);
            lock (this.ThisLock)
            {
                session.LocalChannel = (ushort)this.sessionsByLocalHandle.Add(session);
                if (channel != null)
                {
                    this.sessionsByRemoteHandle.Add(channel.Value, session);
                }
            }

            Utils.Trace(TraceLevel.Info, "{0}: Added {1} (local={2} remote={3})", this, session, session.LocalChannel, channel);
        }
 AmqpLink Microsoft.ServiceBus.Messaging.Amqp.ILinkFactory.CreateLink(AmqpSession session, AmqpLinkSettings linkSettings)
 {
     throw Fx.AssertAndThrow("AmqpTransportManager should always create the Link!");
 }
Esempio n. 10
0
 public ReceivingAmqpLink(AmqpSession session, AmqpLinkSettings settings) :
     base(session, settings)
 {
     this.minTimeout = InitialTimeout;
     this.syncRoot   = new object();
 }
Esempio n. 11
0
 public SendingAmqpLink(AmqpSession session, AmqpLinkSettings settings) : base(session, settings)
 {
     this.pendingDeliveries   = new SerializedWorker <AmqpMessage>(this);
     this.inflightSends       = new WorkCollection <ArraySegment <byte>, SendingAmqpLink.SendAsyncResult, Outcome>(ByteArrayComparer.Instance);
     this.lastFlowRequestTime = DateTime.UtcNow;
 }
Esempio n. 12
0
 public SendingAmqpLink(AmqpSession session, AmqpLinkSettings settings)
     : base(session, settings)
 {
 }
Esempio n. 13
0
 public OutgoingSessionChannel(AmqpSession session)
     : base(session, session.settings.OutgoingBufferSize)
 {
     this.name = session.ToString() + "(out)";
     this.maxFrameSize = session.connection.Settings.MaxFrameSize();
     this.onSettledDeliveryComplete = this.OnSettledDeliveryComplete;
     this.inflightDeliveries = new SerializedWorker<Delivery>(this.OnSendDelivery, null, false);
     this.nextOutgoingId = session.settings.NextOutgoingId.Value;
     this.outgoingWindow = session.settings.OutgoingWindow.Value;
     this.remoteIncomingWindow = session.settings.OutgoingWindow.Value;
     this.IsReceiver = false;
 }
Esempio n. 14
0
            public SessionChannel(AmqpSession session, int bufferSize)
            {
                this.session = session;
                this.nextDeliveryId = session.settings.InitialDeliveryId;
                this.unsettledLwm = this.nextDeliveryId;
                this.deliveryBuffer = new Delivery[Math.Min(bufferSize, SessionChannel.MaxBuferSize)];
                this.dispositionTimer = new IOThreadTimer(DispositionTimerCallback, this, false);
                this.syncRoot = new object();

                int defaultThreshold = this.deliveryBuffer.Length * 2 / 3;
                this.dispositionThreshold = session.settings.DispositionThreshold == 0 ? defaultThreshold : Math.Min(session.settings.DispositionThreshold, defaultThreshold);
                Utils.Trace(TraceLevel.Verbose, "{0}: buffer-size:{1}, disposition-threshold:{2}.", this, this.deliveryBuffer.Length, this.dispositionThreshold);
            }
Esempio n. 15
0
 protected override AmqpLink CreateLink(AmqpSession session)
 {
     AmqpLinkSettings settings = new AmqpLinkSettings();
     settings.LinkName = Guid.NewGuid().ToString("N");
     settings.Source = new Source() { Address = this.Node };
     settings.Role = true;
     ReceivingAmqpLink link = new ReceivingAmqpLink(session, settings);
     link.RegisterMessageListener(this.OnMessage);
     return link;
 }
Esempio n. 16
0
 AmqpLink ILinkFactory.CreateLink(AmqpSession session, AmqpLinkSettings settings)
 {
     bool isReceiver = settings.Role.Value;
     if (isReceiver)
     {
         settings.TransferLimit = uint.MaxValue;
         return new ReceivingAmqpLink(session, settings);
     }
     else
     {
         return new SendingAmqpLink(session, settings);
     }
 }
Esempio n. 17
0
 public IncomingSessionChannel(AmqpSession session) : base(session)
 {
     this.incomingWindow = session.settings.IncomingWindow();
     this.flowThreshold  = this.incomingWindow * 2 / 3;
     base.IsReceiver     = true;
 }
Esempio n. 18
0
 public ReceivingAmqpLink(AmqpSession session, AmqpLinkSettings settings) :
     base(session, settings)
 {
     this.minTimeout = InitialTimeout;
     this.syncRoot = new object();
 }
Esempio n. 19
0
 public OutgoingSessionChannel(AmqpSession session) : base(session)
 {
     this.nextOutgoingId = session.settings.NextOutgoingId.Value;
     this.outgoingWindow = session.settings.OutgoingWindow.Value;
     base.IsReceiver     = false;
 }