Beispiel #1
0
 public SendAsyncResult(SendingAmqpLink link, AmqpMessage message, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.message = message;
     this.message.CompleteCallback = onSendComplete;
     link.SendDelivery(message);
 }
Beispiel #2
0
 public SendAsyncResult(SendingAmqpLink link, AmqpMessage message, TimeSpan timeout, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.message = message;
     this.message.CompleteCallback = onSendComplete;
     link.SendDelivery(message);
 }
Beispiel #3
0
                protected override IEnumerator <IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .AsyncStep> GetAsyncSteps()
                {
                    AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult openLinkAsyncResult = this;
                    IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .BeginCall beginCall = (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sharedAmqpConnection.BeginGetInstance(t, c, s);
                    yield return(openLinkAsyncResult.CallAsync(beginCall, (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, IAsyncResult a) => thisPtr.amqpConnectionSession = thisPtr.sharedAmqpConnection.EndGetInstance(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                    AmqpLinkSettings amqpLinkSetting = new AmqpLinkSettings()
                    {
                        LinkName = string.Concat(this.via.PathAndQuery, "/", Guid.NewGuid())
                    };
                    AmqpLinkSettings amqpLinkSetting1 = amqpLinkSetting;
                    AmqpSymbol       timeoutName      = ClientConstants.TimeoutName;
                    TimeSpan         timeSpan         = base.RemainingTime();

                    amqpLinkSetting1.AddProperty(timeoutName, (uint)timeSpan.TotalMilliseconds);
                    amqpLinkSetting.Role = new bool?(false);
                    amqpLinkSetting.InitialDeliveryCount = new uint?(0);
                    AmqpLinkSettings amqpLinkSetting2 = amqpLinkSetting;
                    Target           target           = new Target()
                    {
                        Address = this.via.PathAndQuery
                    };

                    amqpLinkSetting2.Target = target;
                    this.Link         = new SendingAmqpLink(this.amqpConnectionSession.Item2, amqpLinkSetting);
                    this.Link.Closed += new EventHandler(this.sharedAmqpLink.OnLinkClosed);
                    AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult openLinkAsyncResult1 = this;
                    IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .BeginCall beginCall1 = (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.Link.BeginOpen(t, c, s);
                    IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .EndCall   endCall    = (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, IAsyncResult r) => thisPtr.Link.EndOpen(r);
                    yield return(openLinkAsyncResult1.CallAsync(beginCall1, endCall, (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, TimeSpan t) => thisPtr.Link.Open(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                }
        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 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));
 }
 public SendAsyncResult(SendingAmqpLink link, AmqpMessage message, ArraySegment <byte> deliveryTag, ArraySegment <byte> txnId, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.link        = link;
     this.message     = message;
     this.deliveryTag = deliveryTag;
     this.txnId       = txnId;
     this.link.inflightSends.StartWork(deliveryTag, this);
 }
        protected override void OnAbort()
        {
            SendingAmqpLink sendingAmqpLink = null;

            if (this.sendLink.TryGetOpenedObject(out sendingAmqpLink))
            {
                this.CloseLink(sendingAmqpLink);
            }
            this.clientLinkManager.Close();
        }
        protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
        {
            SendingAmqpLink sendingAmqpLink = null;

            if (!this.sendLink.TryGetOpenedObject(out sendingAmqpLink))
            {
                return(new CompletedAsyncResult(callback, state));
            }
            return(this.messagingFactory.BeginCloseEntity(sendingAmqpLink, timeout, callback, state));
        }
Beispiel #9
0
            public IAsyncResult BeginSend(Message message, TimeSpan timeout, AsyncCallback callback, object state)
            {
                base.ThrowIfDisposedOrNotOpen();
                this.AddHeadersTo(message);
                int maxBufferSize               = this.ChannelFactory.GetMaxBufferSize();
                ArraySegment <byte> nums        = this.MessageEncoder.WriteMessage(message, maxBufferSize, this.ChannelFactory.BufferManager);
                AmqpMessage         amqpMessage = AmqpChannelFactory.AmqpOutputChannel.FinishEncodingMessage(nums, message);
                SendingAmqpLink     link        = this.Link;
                ArraySegment <byte> deliveryTag = AmqpChannelFactory.AmqpOutputChannel.GetDeliveryTag();
                ArraySegment <byte> nums1       = new ArraySegment <byte>();

                return(link.BeginSendMessage(amqpMessage, deliveryTag, nums1, timeout, callback, state));
            }
Beispiel #10
0
            protected override void OnClosing()
            {
                SendingAmqpLink link = this.Link;

                if (link != null)
                {
                    link.Closed -= this.onAmqpObjectClosed;
                }
                AmqpConnection connection = this.Connection;

                if (connection != null)
                {
                    connection.Closed -= this.onAmqpObjectClosed;
                }
                base.OnClosing();
            }
 private static void OnRequestCredit(object state)
 {
     try
     {
         SendingAmqpLink sendingAmqpLink = (SendingAmqpLink)state;
         if (sendingAmqpLink.State == AmqpObjectState.OpenSent || sendingAmqpLink.State == AmqpObjectState.Opened)
         {
             sendingAmqpLink.SendFlow(true);
         }
     }
     catch (Exception exception)
     {
         if (Fx.IsFatal(exception))
         {
             throw;
         }
     }
 }
Beispiel #12
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>();
        }
 private void CloseLink(SendingAmqpLink link)
 {
     link.Session.SafeClose();
 }