/// <summary>
        /// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for receiving and
        /// settling messages from a specific subscription. It uses <see cref="ReceiveMode"/> to specify
        /// how messages are received. Defaults to PeekLock mode. If you want to change the <see cref="ReceiveMode"/>,
        /// use <see cref="CreateReceiver(string, string, ServiceBusReceiverOptions)"/> method.
        /// The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>.
        /// </summary>
        ///
        /// <param name="topicName">The topic to create a <see cref="ServiceBusReceiver"/> for.</param>
        /// <param name="subscriptionName">The subscription specific to the specified topic to create
        /// a <see cref="ServiceBusReceiver"/> for.</param>
        ///
        /// <returns>A <see cref="ServiceBusReceiver"/> scoped to the specified subscription and topic.</returns>
        public virtual ServiceBusReceiver CreateReceiver(
            string topicName,
            string subscriptionName)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusReceiver(
                       connection: Connection,
                       entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       isSessionEntity: false,
                       plugins: Plugins,
                       options: new ServiceBusReceiverOptions()));
        }
        /// <summary>
        /// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for receiving from the
        /// dead letter queue for the specified queue. It uses <see cref="ReceiveMode"/> to specify
        /// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>.
        /// </summary>
        ///
        /// <param name="queueName">The queue to create a <see cref="ServiceBusReceiver"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the
        /// <see cref="ServiceBusReceiver"/>.</param>
        ///
        /// <returns>A <see cref="ServiceBusReceiver"/> scoped to the dead letter queue of the specified
        /// queue.</returns>
        public virtual ServiceBusReceiver CreateDeadLetterReceiver(
            string queueName,
            ServiceBusReceiverOptions options = default)
        {
            ValidateEntityName(queueName);

            return(new ServiceBusReceiver(
                       connection: Connection,
                       entityPath: EntityNameFormatter.FormatDeadLetterPath(queueName),
                       isSessionEntity: false,
                       plugins: Plugins,
                       options: options));
        }
        /// <summary>
        /// Creates a <see cref="ServiceBusProcessor"/> instance that can be used to process messages using
        /// event handlers that are set on the processor. It uses <see cref="ReceiveMode"/> to specify
        /// how messages are received. Defaults to PeekLock mode. If you want to change the <see cref="ReceiveMode"/>,
        /// use <see cref="CreateProcessor(string, string, ServiceBusProcessorOptions)"/> method.
        /// The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusProcessorOptions"/> type.
        /// </summary>
        ///
        /// <param name="topicName">The topic to create a <see cref="ServiceBusProcessor"/> for.</param>
        /// <param name="subscriptionName">The subcription to create a <see cref="ServiceBusProcessor"/> for.</param>
        ///
        /// <returns>A <see cref="ServiceBusProcessor"/> scoped to the specified topic and subscription.</returns>
        public ServiceBusProcessor CreateProcessor(
            string topicName,
            string subscriptionName)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusProcessor(
                       entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection: Connection,
                       isSessionEntity: false,
                       plugins: Plugins,
                       options: new ServiceBusProcessorOptions()));
        }
        /// <summary>
        /// Creates a <see cref="ServiceBusSessionProcessor"/> instance that can be used to process
        /// messages using event handlers that are set on the processor. It uses <see cref="ServiceBusReceiveMode"/> to specify
        /// how messages are received. Defaults to PeekLock mode. The <see cref="ServiceBusReceiveMode"/> is set in <see cref="ServiceBusProcessorOptions"/> type.
        /// </summary>
        ///
        /// <param name="topicName">The topic to create a <see cref="ServiceBusSessionProcessor"/> for.</param>
        /// <param name="subscriptionName">The subscription to create a <see cref="ServiceBusSessionProcessor"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusSessionProcessor"/> to use for configuring the
        /// <see cref="ServiceBusSessionProcessor"/>.</param>
        ///
        /// <returns>A <see cref="ServiceBusProcessor"/> scoped to the specified topic and subscription.</returns>
        public virtual ServiceBusSessionProcessor CreateSessionProcessor(
            string topicName,
            string subscriptionName,
            ServiceBusSessionProcessorOptions options = default)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusSessionProcessor(
                       entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection: Connection,
                       plugins: Plugins,
                       options: options ?? new ServiceBusSessionProcessorOptions()));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="topicName"></param>
        /// <param name="subscriptionName"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public ServiceBusProcessor GetProcessor(
            string topicName,
            string subscriptionName,
            ServiceBusProcessorOptions options)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusProcessor(
                       entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection: Connection,
                       isSessionEntity: false,
                       options: options));
        }
Example #6
0
        /// <summary>
        /// Creates a <see cref="ServiceBusSessionProcessor"/> instance that can be used to process
        /// messages using event handlers that are set on the processor. It uses <see cref="ReceiveMode"/> to specify
        /// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusProcessorOptions"/> type.
        /// </summary>
        ///
        /// <param name="topicName">The topic to create a <see cref="ServiceBusSessionProcessor"/> for.</param>
        /// <param name="subscriptionName">The subcription to create a <see cref="ServiceBusSessionProcessor"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusSessionProcessor"/> to use for configuring the
        /// <see cref="ServiceBusSessionProcessor"/>.</param>
        /// <param name="sessionIds">Optional session IDs to scope the <see cref="ServiceBusSessionProcessor"/> to.
        /// If left blank, the next available session returned from the service will be used.</param>
        ///
        /// <returns>A <see cref="ServiceBusProcessor"/> scoped to the specified topic and subscription.</returns>
        public ServiceBusSessionProcessor CreateSessionProcessor(
            string topicName,
            string subscriptionName,
            ServiceBusProcessorOptions options = default,
            params string[] sessionIds)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusSessionProcessor(
                       entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection: Connection,
                       sessionIds: sessionIds,
                       options: options ?? new ServiceBusProcessorOptions()));
        }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public virtual async Task <ServiceBusReceiver> GetSubscriptionSessionReceiverAsync(
     string subscriptionName,
     string topicName,
     string sessionId = default,
     ServiceBusReceiverOptions options   = default,
     CancellationToken cancellationToken = default) =>
 await ServiceBusReceiver.CreateSessionReceiverAsync(
     EntityNameFormatter.FormatSubscriptionPath(
         topicName,
         subscriptionName),
     Connection,
     sessionId,
     options,
     cancellationToken).ConfigureAwait(false);
        /// <summary>
        /// Creates a <see cref="ServiceBusSessionReceiver"/> instance that can be used for receiving
        /// and settling messages from a specific session-enabled subscription. It uses <see cref="ReceiveMode"/> to specify
        /// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>.
        /// </summary>
        ///
        /// <param name="topicName">The topic to create a <see cref="ServiceBusSessionReceiver"/> for.</param>
        /// <param name="subscriptionName">The session-enabled subscription to create a <see cref="ServiceBusSessionReceiver"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the
        /// <see cref="ServiceBusSessionReceiver"/>.</param>
        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param>
        ///
        /// <remarks>Because this is establishing a session lock, this method performs a service call. If the
        /// sessionId parameter is not specified, and there are no available messages in the queue, this will
        /// throw a <see cref="ServiceBusException"/> with <see cref="ServiceBusException.Reason"/> of <see cref="ServiceBusException.FailureReason.ServiceTimeout"/>.
        /// </remarks>
        ///
        /// <returns>A <see cref="ServiceBusSessionReceiver"/> scoped to the specified queue and a specific session.</returns>
        public virtual async Task <ServiceBusSessionReceiver> CreateSessionReceiverAsync(
            string topicName,
            string subscriptionName,
            ServiceBusSessionReceiverOptions options = default,
            CancellationToken cancellationToken      = default)
        {
            ValidateEntityName(topicName);

            return(await ServiceBusSessionReceiver.CreateSessionReceiverAsync(
                       entityPath : EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection : Connection,
                       options : options,
                       cancellationToken : cancellationToken).ConfigureAwait(false));
        }
Example #9
0
        /// <summary>
        /// Creates a <see cref="ServiceBusSessionProcessor"/> instance that can be used to process
        /// messages using event handlers that are set on the processor.
        /// </summary>
        ///
        /// <param name="topicName">The topic to get a <see cref="ServiceBusSessionProcessor"/> for.</param>
        /// <param name="subscriptionName">The subcription to get a <see cref="ServiceBusSessionProcessor"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusSessionProcessor"/> to use for configuring the
        /// <see cref="ServiceBusSessionProcessor"/>.</param>
        /// <param name="sessionId">An optional session ID to scope the <see cref="ServiceBusSessionProcessor"/> to.
        /// If left blank, the next available session returned from the service will be used.</param>
        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param>
        ///
        /// <returns>A <see cref="ServiceBusProcessor"/> scoped to the specified topic and subscription.</returns>
        public ServiceBusSessionProcessor CreateSessionProcessor(
            string topicName,
            string subscriptionName,
            ServiceBusProcessorOptions options = default,
            string sessionId = default,
            CancellationToken cancellationToken = default)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusSessionProcessor(
                       entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
                       connection: Connection,
                       sessionId: sessionId,
                       options: options ?? new ServiceBusProcessorOptions()));
        }
Example #10
0
        /// <summary>
        /// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for receiving from the
        /// dead letter queue for the specified subscription.
        /// </summary>
        ///
        /// <param name="topicName">The topic to create a <see cref="ServiceBusReceiver"/> for.</param>
        /// <param name="subscriptionName">The subscription to create a <see cref="ServiceBusReceiver"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the
        /// <see cref="ServiceBusReceiver"/>.</param>
        ///
        /// <returns>A <see cref="ServiceBusReceiver"/> scoped to the dead letter queue of the specified
        /// queue.</returns>
        public ServiceBusReceiver CreateDeadLetterReceiver(
            string topicName,
            string subscriptionName,
            ServiceBusReceiverOptions options = default)
        {
            ValidateEntityName(topicName);

            return(new ServiceBusReceiver(
                       connection: Connection,
                       entityPath: EntityNameFormatter.FormatDeadLetterPath(
                           EntityNameFormatter.FormatSubscriptionPath(
                               topicName,
                               subscriptionName)),
                       isSessionEntity: false,
                       options: options));
        }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceBusSessionProcessor"/> class for use with derived types.
 /// </summary>
 /// <param name="client">The client instance to use for the processor.</param>
 /// <param name="topicName">The topic to create a processor for.</param>
 /// <param name="subscriptionName">The subscription to create a processor for.</param>
 /// <param name="options">The set of options to use when configuring the processor.</param>
 protected ServiceBusSessionProcessor(ServiceBusClient client, string topicName, string subscriptionName, ServiceBusSessionProcessorOptions options) :
     this(client?.Connection, EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), options)
 {
 }
 /// <summary>
 /// Formats the dead letter path for either a queue, or a subscription.
 /// </summary>
 /// <param name="entityPath">The name of the queue, or path of the subscription.</param>
 /// <returns>The path as a string of the dead letter entity.</returns>
 public static string FormatDeadLetterPath(string entityPath)
 {
     return(EntityNameFormatter.FormatSubQueuePath(entityPath, EntityNameFormatter.DeadLetterQueueName));
 }
Example #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="topicName"></param>
 /// <param name="subscriptionName"></param>
 /// <returns></returns>
 public ServiceBusProcessor GetSubscriptionProcessor(string topicName, string subscriptionName)
 {
     return(new ServiceBusProcessor(
                Connection,
                EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName)));
 }
Example #14
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));
 }
Example #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="topicName"></param>
 /// <param name="subscriptionName"></param>
 /// <returns></returns>
 public ServiceBusProcessor GetProcessor(string topicName, string subscriptionName) =>
 new ServiceBusProcessor(
     entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
     connection: Connection,
     isSessionEntity: false,
     options: new ServiceBusProcessorOptions());
Example #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="topicName"></param>
 /// <param name="subscriptionName"></param>
 /// <returns></returns>
 public ServiceBusReceiver GetReceiver(string topicName, string subscriptionName) =>
 new ServiceBusReceiver(
     connection: Connection,
     entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName),
     isSessionEntity: false,
     options: new ServiceBusReceiverOptions());