Ejemplo n.º 1
0
 public DisposeAsyncResult(
     ReceivingAmqpLink link,
     ArraySegment <byte> deliveryTag,
     Outcome outcome,
     bool batchable,
     TimeSpan timeout,
     AsyncCallback callback,
     object state)
     : base(callback, state)
 {
     if (link.TryGetDelivery(deliveryTag, out this.delivery))
     {
         delivery.CompleteCallback = onDisposeComplete;
         delivery.UserToken        = this;
         link.DisposeDelivery(delivery, false, outcome);
     }
     else
     {
         // Delivery tag not found
         this.outcome = new Rejected()
         {
             Error = AmqpError.NotFound
         };
         this.Complete(true);
     }
 }
Ejemplo n.º 2
0
 public ReceiveAsyncResult(ReceivingAmqpLink parent, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.parent = parent;
     Fx.Assert(timeout > TimeSpan.Zero, "must have a non-zero timeout");
     this.timeout = timeout;
 }
Ejemplo n.º 3
0
            protected override IEnumerable <AmqpMessage> EndReceive(ReceivingAmqpLink link, IAsyncResult result)
            {
                IEnumerable <AmqpMessage> amqpMessages;

                link.EndReceiveMessages(result, out amqpMessages);
                return(amqpMessages);
            }
Ejemplo n.º 4
0
        public DuplexAmqpLink(AmqpSession session, AmqpLinkSettings settings) : base("duplex")
        {
            MessagingClientEtwProvider.Provider.EventWriteAmqpLogOperation(this, TraceOperation.Create, "Create");
            AmqpLinkSettings amqpLinkSetting = new AmqpLinkSettings()
            {
                Role            = new bool?(false),
                LinkName        = string.Concat(settings.LinkName, ":out"),
                SettleType      = settings.SettleType,
                Source          = new Source(),
                TotalLinkCredit = settings.TotalLinkCredit,
                AutoSendFlow    = settings.AutoSendFlow,
                Target          = settings.Target,
                Properties      = settings.Properties
            };

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

            this.receiver = new ReceivingAmqpLink(session, amqpLinkSetting2);
            this.receiver.SetTotalLinkCredit(amqpLinkSetting2.TotalLinkCredit, true, false);
            this.sender.SafeAddClosed(new EventHandler(this.OnLinkClosed));
            this.receiver.SafeAddClosed(new EventHandler(this.OnLinkClosed));
        }
 public AmqpInputSessionChannel(AmqpChannelListener channelListener, ReceivingAmqpLink link) : base(channelListener)
 {
     this.link         = link;
     this.LocalAddress = new EndpointAddress(channelListener.Uri, new AddressHeader[0]);
     this.id           = string.Concat(base.GetType().Name, this.GetHashCode());
     MessagingClientEtwProvider.Provider.EventWriteAmqpLogOperation(this, TraceOperation.Create, this.LocalAddress);
 }
Ejemplo n.º 6
0
 public DuplexAmqpLink(SendingAmqpLink sender, ReceivingAmqpLink receiver) : base("duplex")
 {
     MessagingClientEtwProvider.Provider.EventWriteAmqpLogOperation(this, TraceOperation.Create, "Create");
     this.sender   = sender;
     this.receiver = receiver;
     this.sender.SafeAddClosed(new EventHandler(this.OnLinkClosed));
     this.receiver.SafeAddClosed(new EventHandler(this.OnLinkClosed));
 }
Ejemplo n.º 7
0
 public DisposeAsyncResult(ReceivingAmqpLink link, ArraySegment <byte> deliveryTag, Outcome outcome, bool batchable, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.link        = link;
     this.deliveryTag = deliveryTag;
     this.batchable   = batchable;
     this.outcome     = outcome;
     this.link.pendingDispositions.StartWork(deliveryTag, this);
 }
Ejemplo n.º 8
0
        protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            ReceivingAmqpLink receivingAmqpLink = null;

            if (!this.receiveLink.TryGetOpenedObject(out receivingAmqpLink))
            {
                return(new CompletedAsyncResult(callback, state));
            }
            return(this.messagingFactory.BeginCloseEntity(receivingAmqpLink, timeout, callback, state));
        }
Ejemplo n.º 9
0
        protected override void OnAbort()
        {
            ReceivingAmqpLink receivingAmqpLink = null;

            if (this.receiveLink.TryGetOpenedObject(out receivingAmqpLink))
            {
                this.CloseLink(receivingAmqpLink);
            }
            this.clientLinkManager.Close();
        }
Ejemplo n.º 10
0
        protected override void OnEndOpen(IAsyncResult result)
        {
            ReceivingAmqpLink receivingAmqpLink = this.receiveLink.EndGetInstance(result);

            base.Mode = (receivingAmqpLink.Settings.SettleType == SettleMode.SettleOnDispose ? ReceiveMode.PeekLock : ReceiveMode.ReceiveAndDelete);
            if (this.sessionReceiver && !((Source)receivingAmqpLink.Settings.Source).FilterSet.TryGetValue <string>(ClientConstants.SessionFilterName, out this.sessionId))
            {
                receivingAmqpLink.Session.SafeClose();
                throw new MessagingException(SRAmqp.AmqpFieldSessionId);
            }
        }
Ejemplo n.º 11
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);
            }
Ejemplo n.º 12
0
            // Find a matching client side link; otherwise wait
            AmqpLink AcceptLink(string node, bool isReceiver, Action <AmqpMessage> messageListener)
            {
                LinkAsyncResult result = null;

                if (this.TryMatchLink(node, true, isReceiver, (r) => { return(new AcceptLinkAsyncResult(r, messageListener, null, null)); }, out result))
                {
                    if (isReceiver)
                    {
                        ReceivingAmqpLink link = (ReceivingAmqpLink)result.Link;
                        link.RegisterMessageListener(messageListener);
                    }

                    result.Signal(null);
                    return(result.Link);
                }

                return(AcceptLinkAsyncResult.End(result));
            }
Ejemplo n.º 13
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>();
        }
Ejemplo n.º 14
0
 protected abstract IAsyncResult BeginReceive(ReceivingAmqpLink link, TimeSpan timeout, AsyncCallback callback, object state);
Ejemplo n.º 15
0
 private void CloseLink(ReceivingAmqpLink link)
 {
     link.Session.SafeClose();
 }
Ejemplo n.º 16
0
 protected override IAsyncResult BeginReceive(ReceivingAmqpLink link, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(link.BeginReceiveRemoteMessage(timeout, callback, state));
 }
Ejemplo n.º 17
0
 private void EnqueueLink(ReceivingAmqpLink link)
 {
     AmqpChannelListener.AmqpInputSessionChannel amqpInputSessionChannel = new AmqpChannelListener.AmqpInputSessionChannel(this, link);
     this.availableChannels.EnqueueAndDispatch(amqpInputSessionChannel, null, false);
 }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
0
 protected abstract IEnumerable <AmqpMessage> EndReceive(ReceivingAmqpLink link, IAsyncResult result);
Ejemplo n.º 20
0
 protected override IAsyncResult BeginReceive(ReceivingAmqpLink link, TimeSpan timeout, AsyncCallback callback, object state)
 {
     Fx.AssertAndThrow(this.maxCount > 0, "we should not have maxCount = 0");
     return(link.BeginReceiveMessages(this.maxCount, timeout, callback, state));
 }
Ejemplo n.º 21
0
 public ReceiveAsyncResult(ReceivingAmqpLink parent, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.parent = parent;
     Fx.Assert(timeout > TimeSpan.Zero, "must have a non-zero timeout");
     this.timeout = timeout;
 }
Ejemplo n.º 22
0
 public ReceiveAsyncResult(ReceivingAmqpLink parent, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.parent  = parent;
     this.timeout = timeout;
 }
Ejemplo n.º 23
0
 public DisposeAsyncResult(
     ReceivingAmqpLink link,
     ArraySegment<byte> deliveryTag, 
     Outcome outcome, 
     bool batchable, 
     TimeSpan timeout, 
     AsyncCallback callback, 
     object state)
     : base(callback, state)
 {
     if (link.TryGetDelivery(deliveryTag, out this.delivery))
     {
         delivery.CompleteCallback = onDisposeComplete;
         delivery.UserToken = this;
         link.DisposeDelivery(delivery, false, outcome);
     }
     else
     {
         // Delivery tag not found
         this.outcome = new Rejected() { Error = AmqpError.NotFound };
         this.Complete(true);
     }
 }