private static void OnSendTokenComplete(IAsyncResult result)
        {
            ActiveClientLinkManager asyncState = (ActiveClientLinkManager)result.AsyncState;

            try
            {
                AmqpCbsLink amqpCbsLink = asyncState.activeClientLink.Link.Session.Connection.Extensions.Find <AmqpCbsLink>() ?? new AmqpCbsLink(asyncState.activeClientLink.Link.Session.Connection);
                DateTime    dateTime    = amqpCbsLink.EndSendToken(result);
                MessagingClientEtwProvider.TraceClient(() => {
                });
                lock (asyncState.syncRoot)
                {
                    asyncState.activeClientLink.AuthorizationValidToUtc = dateTime;
                    asyncState.ScheduleValidityTimer();
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(asyncState.activeClientLink.Link, "EndSendToken", exception.Message));
                asyncState.CancelValidityTimer();
            }
        }
Ejemplo n.º 2
0
 public AmqpMessageSender(AmqpMessagingFactory factory, string entityName, MessagingEntityType?entityType, Microsoft.ServiceBus.RetryPolicy retryPolicy) : base(factory, retryPolicy)
 {
     this.sendLink           = new FaultTolerantObject <SendingAmqpLink>(this, new Action <SendingAmqpLink>(this.CloseLink), new Func <TimeSpan, AsyncCallback, object, IAsyncResult>(this.BeginCreateLink), new Func <IAsyncResult, SendingAmqpLink>(this.EndCreateLink));
     this.messagingFactory   = factory;
     this.entityName         = entityName;
     this.EntityType         = entityType;
     this.clientLinkManager  = new ActiveClientLinkManager(this.messagingFactory);
     this.batchFlushInterval = this.messagingFactory.TransportSettings.BatchFlushInterval;
 }
Ejemplo n.º 3
0
 private AmqpMessageReceiver(AmqpMessagingFactory messagingFactory, string entityName, MessagingEntityType?entityType, string sessionId, bool sessionReceiver, Microsoft.ServiceBus.RetryPolicy retryPolicy, ReceiveMode receiveMode, Microsoft.ServiceBus.Messaging.Filter filter) : base(messagingFactory, retryPolicy, receiveMode, filter)
 {
     this.receiveLink        = new FaultTolerantObject <ReceivingAmqpLink>(this, new Action <ReceivingAmqpLink>(this.CloseLink), new Func <TimeSpan, AsyncCallback, object, IAsyncResult>(this.BeginCreateLink), new Func <IAsyncResult, ReceivingAmqpLink>(this.EndCreateLink));
     this.messagingFactory   = messagingFactory;
     this.entityName         = entityName;
     this.EntityType         = entityType;
     this.sessionId          = sessionId;
     this.sessionReceiver    = sessionReceiver;
     this.PrefetchCount      = this.messagingFactory.PrefetchCount;
     this.lockedMessages     = new ConcurrentDictionary <Guid, ArraySegment <byte> >();
     this.clientLinkManager  = new ActiveClientLinkManager(this.messagingFactory);
     this.batchFlushInterval = this.messagingFactory.TransportSettings.BatchFlushInterval;
 }
        private static void OnLinkExpiration(object state)
        {
            ActiveClientLinkManager activeClientLinkManager = (ActiveClientLinkManager)state;

            try
            {
                MessagingClientEtwProvider.TraceClient(() => {
                });
                AmqpCbsLink amqpCbsLink = activeClientLinkManager.activeClientLink.Link.Session.Connection.Extensions.Find <AmqpCbsLink>() ?? new AmqpCbsLink(activeClientLinkManager.activeClientLink.Link.Session.Connection);
                amqpCbsLink.BeginSendToken(activeClientLinkManager.factory.ServiceBusSecuritySettings.TokenProvider, activeClientLinkManager.factory.Address, activeClientLinkManager.activeClientLink.Audience, activeClientLinkManager.activeClientLink.EndpointUri, activeClientLinkManager.activeClientLink.RequiredClaims, ActiveClientLinkManager.SendTokenTimeout, new AsyncCallback(ActiveClientLinkManager.OnSendTokenComplete), activeClientLinkManager);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpLogError(activeClientLinkManager.activeClientLink.Link, "BeginSendToken", exception.Message));
            }
        }
 internal AmqpSubscriptionClient(AmqpMessagingFactory messagingFactory, string subscriptionPath, ReceiveMode receiveMode) : base(messagingFactory, subscriptionPath, receiveMode)
 {
     this.controlLink              = new FaultTolerantObject <SendingAmqpLink>(this, (SendingAmqpLink link) => link.Session.SafeClose(), new Func <TimeSpan, AsyncCallback, object, IAsyncResult>(this.BeginCreateControlLink), new Func <IAsyncResult, SendingAmqpLink>(this.EndCreateControlLink));
     this.messagingFactory         = messagingFactory;
     this.clientControlLinkManager = new ActiveClientLinkManager(this.messagingFactory);
 }