예제 #1
0
파일: Program.cs 프로젝트: Eclo/amqpnetlite
            public void Process(AttachContext attachContext)
            {
                if (!attachContext.Attach.Role)
                {
                    attachContext.Complete(new Error() { Condition = ErrorCode.NotAllowed, Description = "Only receiver link is allowed." });
                    return;
                }

                string address = ((Source)attachContext.Attach.Source).Address;
                if (!string.Equals("$monitoring", address, StringComparison.OrdinalIgnoreCase))
                {
                    attachContext.Complete(new Error() { Condition = ErrorCode.NotFound, Description = "Cannot find address " + address });
                    return;
                }

                Console.WriteLine("A client has connected. LinkName " + attachContext.Attach.LinkName);
                attachContext.Complete(new MonitoringLinkEndpoint(attachContext.Link), 0);
            }
예제 #2
0
            async Task ProcessAsync(AttachContext attachContext)
            {
                // simulating an async operation required to complete the task
                await Task.Delay(100);

                if (attachContext.Attach.LinkName == "")
                {
                    // how to fail the attach request
                    attachContext.Complete(new Error() { Condition = ErrorCode.InvalidField, Description = "Empty link name not allowed." });
                }
                else if (attachContext.Link.Role)
                {
                    attachContext.Complete(new IncomingLinkEndpoint(), 300);
                }
                else
                {
                    attachContext.Complete(new OutgoingLinkEndpoint(), 0);
                }
            }
예제 #3
0
파일: Program.cs 프로젝트: Eclo/amqpnetlite
            async Task ProcessAsync(AttachContext attachContext)
            {
                // simulating an async operation required to complete the task
                await Task.Delay(100);

                if (attachContext.Attach.LinkName == "")
                {
                    // how to fail the attach request
                    attachContext.Complete(new Error() { Condition = ErrorCode.InvalidField, Description = "Empty link name not allowed." });
                }
                else if (attachContext.Link.Role)
                {
                    var target = attachContext.Attach.Target as Target;
                    if (target != null)
                    {
                        if (target.Address == "slow-queue")
                        {
                            // how to do manual link flow control
                            new SlowLinkEndpoint(attachContext);
                        }
                        else if (target.Address == "shared-queue")
                        {
                            // how to do flow control across links
                            this.sharedLinkEndpoint.AttachLink(attachContext);
                        }
                        else
                        {
                            // default link flow control
                            attachContext.Complete(new IncomingLinkEndpoint(), 300);
                        }
                    }
                }
                else
                {
                    attachContext.Complete(new OutgoingLinkEndpoint(), 0);
                }
            }
 public void Process(AttachContext attachContext)
 {
     if (attachContext.Link.Role &&
         ((Target)attachContext.Attach.Target).Address == Name)
     {
         attachContext.Complete(new IncomingLinkEndpoint(), 30);
     }
     else
     {
         attachContext.Complete(new Error() { Condition = ErrorCode.NotImplemented });
     }
 }
예제 #5
0
        public void Process(AttachContext attachContext)
        {
            if (this.OnLinkAttached != null)
            {
                this.OnLinkAttached(attachContext.Link);
            }

            attachContext.Complete(
                this.factory != null ? this.factory(attachContext.Link) : new TestLinkEndpoint(),
                attachContext.Attach.Role ? 0 : 30);
        }
예제 #6
0
 public void Process(AttachContext attachContext)
 {
     // start a task to process this request
     var task = this.ProcessAsync(attachContext);
 }
예제 #7
0
파일: Program.cs 프로젝트: Eclo/amqpnetlite
 public void AttachLink(AttachContext attachContext)
 {
     this.semaphore.WaitAsync(30000).ContinueWith(
         t =>
         {
             if (!t.Result)
             {
                 attachContext.Complete(new Error() { Condition = ErrorCode.ResourceLimitExceeded });
             }
             else
             {
                 this.semaphore.Release();
                 attachContext.Complete(this, 1);
             }
         });
 }
예제 #8
0
파일: Program.cs 프로젝트: Eclo/amqpnetlite
 public SlowLinkEndpoint(AttachContext attachContext)
 {
     this.link = attachContext.Link;
     this.cts = new CancellationTokenSource();
     link.Closed += (o, e) => this.cts.Cancel();
     attachContext.Complete(this, 0);
     this.link.SetCredit(1, false, false);
 }
 public void Process(AttachContext attachContext)
 {
     attachContext.Complete(new TestLinkEndpoint(), attachContext.Attach.Role ? 0 : 30);
 }