コード例 #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusReceiverClient"/> class.
        /// </summary>
        ///
        /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param>
        /// <param name="sessionId"></param>
        /// <param name="clientOptions">A set of options to apply when configuring the consumer.</param>
        ///
        internal ServiceBusReceiverClient(
            ServiceBusConnection connection,
            string sessionId,
            ServiceBusReceiverClientOptions clientOptions)
        {
            Argument.AssertNotNull(connection, nameof(connection));
            Argument.AssertNotNull(clientOptions, nameof(clientOptions));

            OwnsConnection = false;
            Connection     = connection;
            RetryPolicy    = clientOptions.RetryOptions.ToRetryPolicy();
            ReceiveMode    = clientOptions.ReceiveMode;
            Consumer       = Connection.CreateTransportConsumer(retryPolicy: RetryPolicy, sessionId: sessionId);
        }
コード例 #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusReceiverClient"/> class.
        /// </summary>
        ///
        /// <param name="connectionString">The connection string to use for connecting to the Service Bus namespace; it is expected that the shared key properties are contained in this connection string, but not the Service Bus entity name.</param>
        /// <param name="entityName">The name of the specific Service Bus entity to associate the consumer with.</param>
        /// <param name="clientOptions">A set of options to apply when configuring the consumer.</param>
        /// <param name="sessionId"></param>
        ///
        /// <remarks>
        ///   If the connection string is copied from the Service Bus entity itself, it will contain the name of the desired Service Bus entity,
        ///   and can be used directly without passing the <paramref name="entityName" />.  The name of the Service Bus entity should be
        ///   passed only once, either as part of the connection string or separately.
        /// </remarks>
        ///
        internal ServiceBusReceiverClient(
            string connectionString,
            string entityName,
            string sessionId,
            ServiceBusReceiverClientOptions clientOptions)
        {
            Argument.AssertNotNullOrEmpty(connectionString, nameof(connectionString));
            Argument.AssertNotNull(clientOptions, nameof(clientOptions));

            OwnsConnection = true;
            Connection     = new ServiceBusConnection(connectionString, entityName, clientOptions.ConnectionOptions);
            RetryPolicy    = clientOptions.RetryOptions.ToRetryPolicy();
            ReceiveMode    = clientOptions.ReceiveMode;
            Consumer       = Connection.CreateTransportConsumer(retryPolicy: RetryPolicy, sessionId: sessionId);
        }
コード例 #3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusReceiverClient"/> class.
        /// </summary>
        ///
        /// <param name="fullyQualifiedNamespace">The fully qualified Service Bus namespace to connect to.  This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
        /// <param name="entityName">The name of the specific Service Bus entity to associate the consumer with.</param>
        /// <param name="credential">The Azure managed identity credential to use for authorization.  Access controls may be specified by the Service Bus namespace or the requested Service Bus entity, depending on Azure configuration.</param>
        /// <param name="sessionId"></param>
        /// <param name="clientOptions">A set of options to apply when configuring the consumer.</param>
        ///
        internal ServiceBusReceiverClient(
            string fullyQualifiedNamespace,
            string entityName,
            TokenCredential credential,
            string sessionId,
            ServiceBusReceiverClientOptions clientOptions)
        {
            Argument.AssertNotNullOrEmpty(fullyQualifiedNamespace, nameof(fullyQualifiedNamespace));
            Argument.AssertNotNullOrEmpty(entityName, nameof(entityName));
            Argument.AssertNotNull(credential, nameof(credential));
            Argument.AssertNotNull(clientOptions, nameof(clientOptions));

            OwnsConnection = true;
            Connection     = new ServiceBusConnection(fullyQualifiedNamespace, entityName, credential, clientOptions.ConnectionOptions);
            RetryPolicy    = clientOptions.RetryOptions.ToRetryPolicy();
            ReceiveMode    = clientOptions.ReceiveMode;
            Consumer       = Connection.CreateTransportConsumer(retryPolicy: RetryPolicy, sessionId: sessionId);
        }