/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual async Task <ServiceBusReceiver> GetSessionReceiverAsync(
            string queueName,
            ServiceBusReceiverOptions options = default,
            string sessionId = default,
            CancellationToken cancellationToken = default)
        {
            ValidateEntityName(queueName);

            return(await ServiceBusReceiver.CreateSessionReceiverAsync(
                       entityPath : queueName,
                       connection : Connection,
                       sessionId : sessionId,
                       options : options,
                       cancellationToken : cancellationToken).ConfigureAwait(false));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProcessMessageEventArgs"/> class.
        /// </summary>
        ///
        /// <param name="message">The message to be processed.</param>
        /// <param name="manager">The receiver manager for these event args.</param>
        /// <param name="cancellationToken">The processor's <see cref="System.Threading.CancellationToken"/> instance which will be cancelled
        /// in the event that <see cref="ServiceBusProcessor.StopProcessingAsync"/> is called.
        /// </param>
        internal ProcessMessageEventArgs(
            ServiceBusReceivedMessage message,
            ReceiverManager manager,
            CancellationToken cancellationToken)
        {
            Message = message;

            // manager would be null in scenarios where customers are using the public constructor for testing purposes.
            _receiver         = manager?.Receiver;
            CancellationToken = cancellationToken;

            bool autoRenew = manager?.ShouldAutoRenewMessageLock() == true;

            _receiveActions = new ProcessorReceiveActions(message, manager, autoRenew);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual async Task <ServiceBusReceiver> GetSessionReceiverAsync(
            string topicName,
            string subscriptionName,
            ServiceBusReceiverOptions options = default,
            string sessionId = default,
            CancellationToken cancellationToken = default)
        {
            ValidateEntityName(topicName);

            return(await ServiceBusReceiver.CreateSessionReceiverAsync(
                       entityPath : EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection : Connection,
                       sessionId : sessionId,
                       options : options,
                       cancellationToken : cancellationToken).ConfigureAwait(false));
        }
Пример #4
0
        public virtual async Task CloseReceiverIfNeeded(
            CancellationToken cancellationToken,
            bool forceClose = false)
        {
            var capturedReceiver = Receiver;

            if (capturedReceiver != null)
            {
                try
                {
                    await capturedReceiver.DisposeAsync().ConfigureAwait(false);
                }
                finally
                {
                    Receiver = null;
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal static async Task <ServiceBusReceiver> CreateSessionReceiverAsync(
            string queueName,
            ServiceBusConnection connection,
            string sessionId = default,
            ServiceBusReceiverOptions options   = default,
            CancellationToken cancellationToken = default)
        {
            options = options?.Clone() ?? new ServiceBusReceiverOptions();

            var receiver = new ServiceBusReceiver(
                connection: connection,
                entityName: queueName,
                isSessionEntity: true,
                sessionId: sessionId,
                options: options);
            await receiver.OpenLinkAsync(cancellationToken).ConfigureAwait(false);

            return(receiver);
        }
Пример #6
0
 public ReceiverManager(
     ServiceBusProcessor processor,
     EntityScopeFactory scopeFactory,
     IList <ServiceBusPlugin> plugins)
 {
     Processor        = processor;
     ProcessorOptions = processor.Options;
     _receiverOptions = new ServiceBusReceiverOptions
     {
         ReceiveMode   = ProcessorOptions.ReceiveMode,
         PrefetchCount = ProcessorOptions.PrefetchCount,
     };
     _maxReceiveWaitTime = ProcessorOptions.MaxReceiveWaitTime;
     _plugins            = plugins;
     Receiver            = new ServiceBusReceiver(
         connection: Processor.Connection,
         entityPath: Processor.EntityPath,
         isSessionEntity: false,
         plugins: _plugins,
         options: _receiverOptions);
     _scopeFactory = scopeFactory;
 }
Пример #7
0
 public ReceiverManager(
     ServiceBusProcessor processor,
     EntityScopeFactory scopeFactory)
 {
     Processor        = processor;
     ProcessorOptions = processor.Options;
     _receiverOptions = new ServiceBusReceiverOptions
     {
         ReceiveMode   = ProcessorOptions.ReceiveMode,
         PrefetchCount = ProcessorOptions.PrefetchCount,
         // Pass None for subqueue since the subqueue has already
         // been taken into account when computing the EntityPath of the processor.
         SubQueue = SubQueue.None
     };
     _maxReceiveWaitTime = ProcessorOptions.MaxReceiveWaitTime;
     Receiver            = new ServiceBusReceiver(
         connection: Processor.Connection,
         entityPath: Processor.EntityPath,
         isSessionEntity: false,
         isProcessor: true,
         options: _receiverOptions);
     _scopeFactory = scopeFactory;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessMessageEventArgs"/> class.
 /// </summary>
 ///
 /// <param name="message"></param>
 /// <param name="receiver"></param>
 /// <param name="cancellationToken"></param>
 internal ProcessMessageEventArgs(ServiceBusReceivedMessage message, ServiceBusReceiver receiver, CancellationToken cancellationToken)
 {
     Message           = message;
     Receiver          = receiver;
     CancellationToken = cancellationToken;
 }
Пример #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="topicName"></param>
 /// <param name="subscriptionName"></param>
 /// <returns></returns>
 public ServiceBusReceiver GetSubscriptionReceiver(string topicName, string subscriptionName)
 {
     return(ServiceBusReceiver.CreateReceiver(
                EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                Connection));
 }
Пример #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="queueName"></param>
 /// <returns></returns>
 public ServiceBusReceiver GetReceiver(string queueName)
 {
     return(ServiceBusReceiver.CreateReceiver(
                queueName,
                Connection));
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessMessageEventArgs"/> class.
 /// </summary>
 ///
 /// <param name="message">The message to be processed.</param>
 /// <param name="receiver">The receiver instance that can be used to perform message settlement.</param>
 /// <param name="cancellationToken">The processor's <see cref="System.Threading.CancellationToken"/> instance which will be cancelled
 /// in the event that <see cref="ServiceBusProcessor.StopProcessingAsync"/> is called.
 /// </param>
 public ProcessMessageEventArgs(ServiceBusReceivedMessage message, ServiceBusReceiver receiver, CancellationToken cancellationToken) :
     this(message, manager : null, cancellationToken)
 {
     _receiver = receiver;
 }