コード例 #1
0
        protected override async Task <MessageSession> OnAcceptMessageSessionAsync(string sessionId, TimeSpan serverWaitTime)
        {
            AmqpMessageReceiver receiver = new AmqpMessageReceiver(
                this.SubscriptionPath,
                MessagingEntityType.Subscriber,
                this.Mode,
                this.ServiceBusConnection.PrefetchCount,
                this.ServiceBusConnection,
                this.CbsTokenProvider,
                sessionId,
                true);

            try
            {
                await receiver.GetSessionReceiverLinkAsync(serverWaitTime).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                await receiver.CloseAsync().ConfigureAwait(false);

                throw AmqpExceptionHelper.GetClientException(exception);
            }
            MessageSession session = new AmqpMessageSession(receiver.SessionId, receiver.LockedUntilUtc, receiver);

            return(session);
        }
コード例 #2
0
        public async Task <IMessageSession> AcceptMessageSessionAsync(string sessionId, TimeSpan serverWaitTime)
        {
            MessagingEventSource.Log.AmqpSessionClientAcceptMessageSessionStart(
                this.ClientId,
                this.EntityPath,
                this.ReceiveMode,
                this.PrefetchCount,
                sessionId);

            AmqpMessageReceiver receiver = new AmqpMessageReceiver(
                this.EntityPath,
                this.EntityType,
                this.ReceiveMode,
                this.PrefetchCount,
                this.ServiceBusConnection,
                this.CbsTokenProvider,
                sessionId,
                this.RetryPolicy,
                true);

            try
            {
                await this.RetryPolicy.RunOperation(
                    async() =>
                {
                    await receiver.GetSessionReceiverLinkAsync(serverWaitTime).ConfigureAwait(false);
                }, serverWaitTime)
                .ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                MessagingEventSource.Log.AmqpSessionClientAcceptMessageSessionException(
                    this.ClientId,
                    this.EntityPath,
                    exception);

                await receiver.CloseAsync().ConfigureAwait(false);

                throw AmqpExceptionHelper.GetClientException(exception);
            }

            MessageSession session = new AmqpMessageSession(receiver.SessionId, receiver.LockedUntilUtc, receiver, this.RetryPolicy);

            MessagingEventSource.Log.AmqpSessionClientAcceptMessageSessionStop(
                this.ClientId,
                this.EntityPath,
                session.SessionId);

            return(session);
        }
コード例 #3
0
        protected override async Task <MessageSession> OnAcceptMessageSessionAsync(string sessionId)
        {
            AmqpMessageReceiver receiver = new AmqpMessageReceiver(this.SubscriptionPath, MessagingEntityType.Subscriber, this.Mode, this.ServiceBusConnection.PrefetchCount, this.ServiceBusConnection, this.CbsTokenProvider, sessionId, true);

            try
            {
                await receiver.GetSessionReceiverLinkAsync().ConfigureAwait(false);
            }
            catch (AmqpException exception)
            {
                // ToDo: Abort the Receiver here
                AmqpExceptionHelper.ToMessagingContract(exception.Error, false);
            }
            MessageSession session = new AmqpMessageSession(receiver.SessionId, receiver.LockedUntilUtc, receiver);

            return(session);
        }