/// <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);
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entityName"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public ServiceBusSender GetSender(string entityName, ServiceBusSenderOptions options)
 {
     return(new ServiceBusSender(
                Connection,
                options,
                entityName: entityName));
 }
 /// <summary>
 /// Creates a <see cref="ServiceBusSender"/> instance that can be used for sending messages to a specific
 /// queue or topic.
 /// </summary>
 ///
 /// <param name="queueOrTopicName">The queue or topic to create a <see cref="ServiceBusSender"/> for.</param>
 /// <param name="options">The set of <see cref="ServiceBusSenderOptions"/> to use for configuring
 /// this <see cref="ServiceBusSender"/>.</param>
 ///
 /// <returns>A <see cref="ServiceBusSender"/> scoped to the specified queue or topic.</returns>
 internal virtual ServiceBusSender CreateSender(string queueOrTopicName, ServiceBusSenderOptions options)
 {
     return(new ServiceBusSender(
                entityPath: queueOrTopicName,
                options: options,
                connection: Connection,
                plugins: Plugins));
 }
Example #4
0
        /// <summary>
        /// Creates a <see cref="ServiceBusSender"/> instance that can be used for sending messages to a specific
        /// queue or topic.
        /// </summary>
        ///
        /// <param name="queueOrTopicName">The queue or topic to create a <see cref="ServiceBusSender"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusSenderOptions"/> to use for configuring
        /// this <see cref="ServiceBusSender"/>.</param>
        ///
        /// <returns>A <see cref="ServiceBusSender"/> scoped to the specified queue or topic.</returns>
        public ServiceBusSender CreateSender(string queueOrTopicName, ServiceBusSenderOptions options)
        {
            ValidateSendViaEntityName(queueOrTopicName, options?.ViaQueueOrTopicName);

            return(new ServiceBusSender(
                       entityPath: queueOrTopicName,
                       options: options,
                       connection: Connection));
        }
        /// <summary>
        /// Creates a <see cref="ServiceBusSender"/> instance that can be used for sending messages to a specific
        /// queue or topic.
        /// </summary>
        ///
        /// <param name="queueOrTopicName">The queue or topic to create a <see cref="ServiceBusSender"/> for.</param>
        /// <param name="options">The set of <see cref="ServiceBusSenderOptions"/> to use for configuring
        /// this <see cref="ServiceBusSender"/>.</param>
        ///
        /// <returns>A <see cref="ServiceBusSender"/> scoped to the specified queue or topic.</returns>
        public virtual ServiceBusSender CreateSender(string queueOrTopicName, ServiceBusSenderOptions options)
        {
            ValidateSendViaEntityName(queueOrTopicName, options?.TransactionQueueOrTopicName);

            return(new ServiceBusSender(
                       entityPath: queueOrTopicName,
                       options: options,
                       connection: Connection,
                       plugins: Plugins));
        }
Example #6
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusSender"/> class.
        /// </summary>
        /// <param name="entityPath"></param>
        /// <param name="connection"></param>
        /// <param name="options">A set of options to apply when configuring the producer.</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(
            string entityPath,
            ServiceBusConnection connection,
            ServiceBusSenderOptions options)
        {
            Argument.AssertNotNull(connection, nameof(connection));
            Argument.AssertNotNull(options, nameof(options));
            Argument.AssertNotNull(options.RetryOptions, nameof(options.RetryOptions));
            Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath));
            connection.ThrowIfClosed();

            EntityPath   = entityPath;
            Identifier   = DiagnosticUtilities.GenerateIdentifier(EntityPath);
            options      = options?.Clone() ?? new ServiceBusSenderOptions();
            _connection  = connection;
            _retryPolicy = options.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);
        }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entityName"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public ServiceBusSender GetSender(string entityName, ServiceBusSenderOptions options) =>
 new ServiceBusSender(
     entityPath: entityName,
     connection: Connection,
     options: options);