/// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusSender"/> class.
        /// </summary>
        /// <param name="entityPath">The entity path to send the message to.</param>
        /// <param name="options">The set of <see cref="ServiceBusSenderOptions"/> to use for configuring
        /// this <see cref="ServiceBusSender"/>.</param>
        /// <param name="connection">The connection for the sender.</param>
        ///
        internal ServiceBusSender(
            string entityPath,
            ServiceBusSenderOptions options,
            ServiceBusConnection connection)
        {
            Logger.ClientCreateStart(typeof(ServiceBusSender), connection?.FullyQualifiedNamespace, entityPath);
            try
            {
                Argument.AssertNotNull(connection, nameof(connection));
                Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions));
                Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath));
                connection.ThrowIfClosed();

                options       = options?.Clone() ?? new ServiceBusSenderOptions();
                EntityPath    = entityPath;
                ViaEntityPath = options.ViaQueueOrTopicName;
                Identifier    = DiagnosticUtilities.GenerateIdentifier(EntityPath);
                _connection   = connection;
                _retryPolicy  = _connection.RetryOptions.ToRetryPolicy();
                _innerSender  = _connection.CreateTransportSender(
                    entityPath,
                    ViaEntityPath,
                    _retryPolicy,
                    Identifier);
                _scopeFactory = new EntityScopeFactory(EntityPath, FullyQualifiedNamespace);
            }
            catch (Exception ex)
            {
                Logger.ClientCreateException(typeof(ServiceBusSender), connection?.FullyQualifiedNamespace, entityPath, ex);
                throw;
            }
            Logger.ClientCreateComplete(typeof(ServiceBusSender), Identifier);
        }
Beispiel #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusSenderClient"/> class.
        /// </summary>
        ///
        /// <param name="connection">The connection to use as the basis for delegation of client-type operations.</param>
        /// <param name="transportProducer">The transport producer instance to use as the basis for service communication.</param>
        ///
        /// <remarks>
        ///   This constructor is intended to be used internally for functional
        ///   testing only.
        /// </remarks>
        ///
        internal ServiceBusSenderClient(
            ServiceBusConnection connection,
            TransportSender transportProducer)
        {
            Argument.AssertNotNull(connection, nameof(connection));
            Argument.AssertNotNull(transportProducer, nameof(transportProducer));

            OwnsConnection = false;
            Connection     = connection;
            InnerSender    = transportProducer;
        }
Beispiel #3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusSender"/> class.
        /// </summary>
        /// <param name="entityPath">The entity path to send the message to.</param>
        /// <param name="connection">The connection for the sender.</param>
        ///
        internal ServiceBusSender(
            string entityPath,
            ServiceBusConnection connection)
        {
            Argument.AssertNotNull(connection, nameof(connection));
            Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions));
            Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath));
            connection.ThrowIfClosed();

            EntityPath   = entityPath;
            Identifier   = DiagnosticUtilities.GenerateIdentifier(EntityPath);
            _connection  = connection;
            _retryPolicy = _connection.RetryOptions.ToRetryPolicy();
            _innerSender = _connection.CreateTransportSender(
                entityPath,
                _retryPolicy);
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusSender"/> class.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="options">A set of options to apply when configuring the producer.</param>
        /// <param name="entityName"></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  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 ServiceBusSender(
            ServiceBusConnection connection,
            ServiceBusSenderOptions options,
            string entityName)
        {
            if (entityName == null)
            {
                throw new ArgumentException();
            }

            options           = options?.Clone() ?? new ServiceBusSenderOptions();
            ClientDiagnostics = new ClientDiagnostics(options);
            OwnsConnection    = false;
            EntityName        = entityName;
            _connection       = connection;
            _retryPolicy      = options.RetryOptions.ToRetryPolicy();
            _innerSender      = _connection.CreateTransportSender(
                entityName,
                _retryPolicy);
        }