コード例 #1
0
        protected override bool OpenInternal()
        {
            this.messageQueue        = new Queue <AmqpMessage>();
            this.waiterList          = new LinkedList <ReceivingAmqpLink.ReceiveAsyncResult>();
            this.pendingDispositions = new WorkCollection <ArraySegment <byte>, ReceivingAmqpLink.DisposeAsyncResult, Outcome>(ByteArrayComparer.Instance);
            bool flag = base.OpenInternal();

            if (base.LinkCredit > 0)
            {
                base.SendFlow(false);
            }
            return(flag);
        }
 public void Abort()
 {
     this.closed = true;
     ActionItem.Schedule((object o) => {
         TWork tWork;
         WorkCollection <TKey, TWork, TOutcome> workCollection = (WorkCollection <TKey, TWork, TOutcome>)o;
         foreach (TKey tKey in new List <TKey>(workCollection.pendingWork.Keys))
         {
             if (!workCollection.pendingWork.TryRemove(tKey, out tWork))
             {
                 continue;
             }
             tWork.Cancel(false, new OperationCanceledException());
         }
     }, this);
 }
コード例 #3
0
        public RequestResponseAmqpLink(AmqpSession session, AmqpLinkSettings settings) : base("requestresponseamqplink")
        {
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] identifier = new object[] { session.Connection.Identifier, session.Identifier, base.Identifier };
            this.Name = string.Format(invariantCulture, "{0}:{1}:{2}", identifier);
            Source source = (Source)settings.Source;
            string str    = source.Address.ToString();
            Guid   guid   = Guid.NewGuid();

            source.Address = string.Concat(str, "/", guid.ToString("N"));
            this.replyTo   = source.Address;
            AmqpLinkSettings amqpLinkSetting = new AmqpLinkSettings()
            {
                Role       = new bool?(false),
                LinkName   = string.Concat(this.Name, ":sender"),
                SettleType = settings.SettleType,
                Source     = new Source(),
                Target     = settings.Target,
                Properties = settings.Properties
            };

            this.sender         = new SendingAmqpLink(session, amqpLinkSetting);
            this.sender.Closed += new EventHandler(this.OnLinkClosed);
            AmqpLinkSettings amqpLinkSetting1 = new AmqpLinkSettings()
            {
                Role            = new bool?(true),
                LinkName        = string.Concat(this.Name, ":receiver"),
                SettleType      = settings.SettleType,
                Source          = settings.Source,
                TotalLinkCredit = settings.TotalLinkCredit,
                AutoSendFlow    = settings.AutoSendFlow,
                Target          = new Target(),
                Properties      = settings.Properties
            };

            this.receiver = new ReceivingAmqpLink(session, amqpLinkSetting1);
            this.receiver.SetTotalLinkCredit(amqpLinkSetting1.TotalLinkCredit, true, false);
            this.receiver.RegisterMessageListener(new Action <AmqpMessage>(this.OnResponseMessage));
            this.receiver.Closed += new EventHandler(this.OnLinkClosed);
            this.inflightRequests = new WorkCollection <MessageId, RequestResponseAmqpLink.RequestAsyncResult, AmqpMessage>();
        }
コード例 #4
0
 public void Start()
 {
     if (!this.link.DisposeDelivery(this.deliveryTag, false, this.outcome, this.batchable))
     {
         WorkCollection <ArraySegment <byte>, ReceivingAmqpLink.DisposeAsyncResult, Outcome> workCollection = this.link.pendingDispositions;
         ArraySegment <byte> nums     = this.deliveryTag;
         Rejected            rejected = new Rejected()
         {
             Error = AmqpError.NotFound
         };
         workCollection.CompleteWork(nums, true, rejected);
     }
 }
コード例 #5
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;
 }