internal AmqpEventDataSender(AmqpEventHubClient eventHubClient, string partitionId)
            : base(eventHubClient, partitionId)
        {
            this.Path = !string.IsNullOrEmpty(partitionId)
                ? $"{eventHubClient.EventHubName}/Partitions/{partitionId}"
                : eventHubClient.EventHubName;

            this.SendLinkManager   = new FaultTolerantAmqpObject <SendingAmqpLink>(this.CreateLinkAsync, this.CloseSession);
            this.clientLinkManager = new ActiveClientLinkManager((AmqpEventHubClient)this.EventHubClient);
            this.MaxMessageSize    = 256 * 1024; // Default. Updated when link is opened
        }
        internal AmqpEventDataSender(AmqpEventHubClient eventHubClient, string partitionId)
            : base(eventHubClient, partitionId)
        {
            if (!string.IsNullOrEmpty(partitionId))
            {
                this.Path = $"{eventHubClient.EventHubName}/Partitions/{partitionId}";
            }
            else
            {
                this.Path = eventHubClient.EventHubName;
            }

            this.SendLinkManager   = new FaultTolerantAmqpObject <SendingAmqpLink>(this.CreateLinkAsync, this.CloseSession);
            this.clientLinkManager = new ActiveClientLinkManager((AmqpEventHubClient)this.EventHubClient);
        }
Exemplo n.º 3
0
        public AmqpPartitionReceiver(
            AmqpEventHubClient eventHubClient,
            string consumerGroupName,
            string partitionId,
            EventPosition eventPosition,
            long?epoch,
            ReceiverOptions receiverOptions)
            : base(eventHubClient, consumerGroupName, partitionId, eventPosition, epoch, receiverOptions)
        {
            string entityPath = eventHubClient.ConnectionStringBuilder.EntityPath;

            this.Path = $"{entityPath}/ConsumerGroups/{consumerGroupName}/Partitions/{partitionId}";
            this.ReceiveLinkManager = new FaultTolerantAmqpObject <ReceivingAmqpLink>(this.CreateLinkAsync, this.CloseSession);
            this.receivePumpLock    = new object();
            this.clientLinkManager  = new ActiveClientLinkManager((AmqpEventHubClient)this.EventHubClient);
        }
Exemplo n.º 4
0
        public AmqpPartitionReceiver(
            AmqpEventHubClient eventHubClient,
            string consumerGroupName,
            string partitionId,
            string startOffset,
            bool offsetInclusive,
            DateTime?startTime,
            long?epoch)
            : base(eventHubClient, consumerGroupName, partitionId, startOffset, offsetInclusive, startTime, epoch)
        {
            string entityPath = eventHubClient.ConnectionStringBuilder.EntityPath;

            this.Path = $"{entityPath}/ConsumerGroups/{consumerGroupName}/Partitions/{partitionId}";
            this.ReceiveLinkManager = new FaultTolerantAmqpObject <ReceivingAmqpLink>(this.CreateLinkAsync, this.CloseSession);
            this.receivePumpLock    = new object();
            this.clientLinkManager  = new ActiveClientLinkManager((AmqpEventHubClient)this.EventHubClient);
        }
Exemplo n.º 5
0
        static async void OnLinkExpiration(object state)
        {
            ActiveClientLinkManager thisPtr = (ActiveClientLinkManager)state;

            Fx.Assert(thisPtr.activeClientLink != null, "activeClientLink cant be null");
            Fx.Assert(thisPtr.activeClientLink.IsClientToken, "timer can't fire if the link auth is not based on a client token");

            try
            {
                //DNX_TODO: MessagingClientEtwProvider.Provider.EventWriteAmqpManageLink("Before SendToken", thisPtr.activeClientLink.LinkObject, string.Empty);

                AmqpCbsLink cbsLink = thisPtr.activeClientLink.Connection.Extensions.Find <AmqpCbsLink>();
                if (cbsLink == null)
                {
                    cbsLink = new AmqpCbsLink(thisPtr.activeClientLink.Connection);
                }

                var validTo = await cbsLink.SendTokenAsync(
                    thisPtr.eventHubClient.CbsTokenProvider,
                    thisPtr.eventHubClient.ConnectionStringBuilder.Endpoint,
                    thisPtr.activeClientLink.Audience, thisPtr.activeClientLink.EndpointUri,
                    thisPtr.activeClientLink.RequiredClaims,
                    ActiveClientLinkManager.SendTokenTimeout);

                //DNX_TODO: MessagingClientEtwProvider.Provider.EventWriteAmqpManageLink("After SendToken", thisPtr.activeClientLink.LinkObject, validTo.ToString(CultureInfo.InvariantCulture));

                lock (thisPtr.syncRoot)
                {
                    thisPtr.activeClientLink.AuthorizationValidToUtc = validTo;
                    thisPtr.ScheduleValidityTimer();
                }
            }
            catch
            {
                //DNX_TODO:
                //if (Fx.IsFatal(exception))
                //{
                //    throw;
                //}

                //DNX_TODO: MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(thisPtr.activeClientLink.LinkObject, "BeginSendToken", exception.Message);

                // failed to refresh token, no need to do anything since the server will shut the link itself
                thisPtr.CancelValidityTimer();
            }
        }