Beispiel #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);
        }
Beispiel #2
0
        public static AmqpLinkSettings Create(Attach attach)
        {
            AmqpLinkSettings settings = new AmqpLinkSettings();
            settings.LinkName = attach.LinkName;
            settings.Role = !attach.Role.Value;
            settings.Source = attach.Source;
            settings.Target = attach.Target;
            settings.SndSettleMode = attach.SndSettleMode;
            settings.RcvSettleMode = attach.RcvSettleMode;
            settings.MaxMessageSize = attach.MaxMessageSize;
            settings.Properties = attach.Properties;
            if (settings.Role.Value)
            {
                settings.TransferLimit = AmqpConstants.DefaultLinkCredit;
            }
            else
            {
                settings.InitialDeliveryCount = 0;
            }

            return settings;
        }
Beispiel #3
0
 public ReceivingAmqpLink(AmqpSession session, AmqpLinkSettings settings) :
     base(session, settings)
 {
     this.minTimeout = InitialTimeout;
     this.syncRoot = new object();
 }
Beispiel #4
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);
     }
 }
Beispiel #5
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;
 }
Beispiel #6
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);
 }
Beispiel #7
0
 public SendingAmqpLink(AmqpSession session, AmqpLinkSettings settings)
     : base(session, settings)
 {
 }