예제 #1
0
        public void AttachLink(AmqpLink link)
        {
            Fx.Assert(link.Session == this, "The link is not owned by this session.");
            link.Closed += new EventHandler(this.OnLinkClosed);

            lock (this.ThisLock)
            {
                this.links.Add(link.Name, link);
                link.LocalHandle = this.linksByLocalHandle.Add(link);
            }

            Utils.Trace(TraceLevel.Info, "{0}: Attach {1} '{2}' ({3})", this, link, link.Name, link.IsReceiver ? "receiver" : "sender");
        }
예제 #2
0
 protected override void OnSignal(AmqpLink link)
 {
 }
예제 #3
0
                public OpenLinkAsyncResult(Listener listener, AmqpLink link, AsyncCallback callback, object state)
                    : base(callback, state)
                {
                    this.Link = link;

                    string node = link.IsReceiver ? ((Target)link.Settings.Target).Address.ToString() : ((Source)link.Settings.Source).Address.ToString();
                    LinkAsyncResult result = null;
                    if (listener.TryMatchLink(node, false, link.IsReceiver, (r) => { return this; }, out result))
                    {
                        result.Signal(link);

                        this.Complete(true);
                    }
                }
예제 #4
0
 protected override void OnSignal(AmqpLink link)
 {
     Fx.Assert(link != null, "Accept cannot be completed with a null link");
     this.Link = link;
     if (this.isReceiver)
     {
         ((ReceivingAmqpLink)link).RegisterMessageListener(this.messageListener);
     }
 }
예제 #5
0
 protected abstract void OnSignal(AmqpLink link);
예제 #6
0
 public void Signal(AmqpLink link)
 {
     this.OnSignal(link);
     this.Complete(false);
 }
예제 #7
0
 IAsyncResult ILinkFactory.BeginOpenLink(AmqpLink link, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return new OpenLinkAsyncResult(this, link, callback, state);
 }
예제 #8
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);
                }
 protected abstract IAsyncResult OnBeginOpenLink(AmqpLink link, TimeSpan timeout, AsyncCallback callback, object state);
 IAsyncResult Microsoft.ServiceBus.Messaging.Amqp.ILinkFactory.BeginOpenLink(AmqpLink link, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(this.OnBeginOpenLink(link, timeout, callback, state));
 }
예제 #11
0
        bool TryCreateRemoteLink(Attach attach, out AmqpLink link)
        {
            link = null;
            AmqpLinkSettings linkSettings = AmqpLinkSettings.Create(attach);

            try
            {
                link = this.linkFactory.CreateLink(this, linkSettings);
                link.RemoteHandle = attach.Handle;
                this.linksByRemoteHandle.Add(attach.Handle.Value, link);
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                attach.Source = null;
                attach.Target = null;
                this.SendCommand(attach);

                if (link != null)
                {
                    link.TryClose(exception);
                }

                return false;
            }

            return true;
        }
예제 #12
0
 public void DisposeDelivery(AmqpLink link, Delivery delivery, bool settled, DeliveryState state)
 {
     if (link.IsReceiver)
     {
         this.incomingChannel.DisposeDelivery(delivery, settled, state);
     }
     else
     {
         this.outgoingChannel.DisposeDelivery(delivery, settled, state);
     }
 }
예제 #13
0
            public void OnReceiveTransfer(AmqpLink link, Transfer transfer)
            {
                if (!transferEverReceived)
                {
                    this.OnReceiveFirstTransfer(transfer);
                    this.transferEverReceived = true;
                }

                lock (this.SyncRoot)
                {
                    if (this.incomingWindow == 0)
                    {
                        Utils.Trace(TraceLevel.Verbose, "{0}: Window closed", this);
                        throw new AmqpException(AmqpError.WindowViolation);
                    }

                    this.nextIncomingId.Increment();
                    --this.incomingWindow;
                }

                this.pendingTransfers.DoWork(new Tuple<AmqpLink, Transfer>(link, transfer));
            }