Exemple #1
1
 /// <summary>
 /// Constructs the saga storage
 /// </summary>
 public PostgreSqlSagaStorage(PostgresConnectionHelper connectionHelper, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
 {
     _connectionHelper = connectionHelper;
     _dataTableName = dataTableName;
     _indexTableName = indexTableName;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the subscription storage, storing subscriptions in the specified <paramref name="tableName"/>.
 /// If <paramref name="isCentralized"/> is true, subscribing/unsubscribing will be short-circuited by manipulating
 /// subscriptions directly, instead of requesting via messages
 /// </summary>
 public PostgreSqlSubscriptionStorage(PostgresConnectionHelper connectionHelper, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     _connectionHelper = connectionHelper;
     _tableName        = tableName;
     IsCentralized     = isCentralized;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #3
0
        /// <summary>
        /// Creates the saga storage
        /// </summary>
        public AzureStorageSagaStorage(CloudStorageAccount cloudStorageAccount,
                                       IRebusLoggerFactory loggerFactory,
                                       string tableName     = "RebusSagaIndex",
                                       string containerName = "RebusSagaStorage")
        {
            if (cloudStorageAccount == null)
            {
                throw new ArgumentNullException(nameof(cloudStorageAccount));
            }
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }
            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }
            if (containerName == null)
            {
                throw new ArgumentNullException(nameof(containerName));
            }

            _tableReference     = cloudStorageAccount.CreateCloudTableClient().GetTableReference(tableName.ToLowerInvariant());
            _containerReference = cloudStorageAccount.CreateCloudBlobClient().GetContainerReference(containerName.ToLowerInvariant());
            _log = loggerFactory.GetCurrentClassLogger();
        }
Exemple #4
0
 public ReplyHandlerStep(ConcurrentDictionary <string, TimedMessage> messages, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, TimeSpan replyMaxAge)
 {
     _messages    = messages;
     _replyMaxAge = replyMaxAge;
     _log         = rebusLoggerFactory.GetCurrentClassLogger();
     _cleanupTask = asyncTaskFactory.Create("CleanupAbandonedRepliesTask", CleanupAbandonedReplies);
 }
Exemple #5
0
 /// <summary>
 /// Constructs the step with the given saga storage
 /// </summary>
 public LoadSagaDataStep(ISagaStorage sagaStorage, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (sagaStorage == null) throw new ArgumentNullException(nameof(sagaStorage));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _sagaStorage = sagaStorage;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the saga storage, using the specified connection provider and tables for persistence.
 /// </summary>
 public SqlServerSagaStorage(IDbConnectionProvider connectionProvider, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
 {
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _connectionProvider = connectionProvider;
     _dataTableName      = dataTableName;
     _indexTableName     = indexTableName;
 }
 /// <summary>
 /// Creates the data storage
 /// </summary>
 public FileSystemDataBusStorage(string directoryPath, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (directoryPath == null) throw new ArgumentNullException(nameof(directoryPath));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _directoryPath = directoryPath;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the step, using the given transport and settings
 /// </summary>
 public SimpleRetryStrategyStep(ITransport transport, SimpleRetryStrategySettings simpleRetryStrategySettings, IErrorTracker errorTracker, IRebusLoggerFactory rebusLoggerFactory)
 {
     _transport = transport;
     _simpleRetryStrategySettings = simpleRetryStrategySettings;
     _errorTracker = errorTracker;
     _log          = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #9
0
 /// <summary>
 /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription
 /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true
 /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests
 /// </summary>
 public SqlServerSubscriptionStorage(IDbConnectionProvider connectionProvider, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     IsCentralized       = isCentralized;
     _log                = rebusLoggerFactory.GetCurrentClassLogger();
     _connectionProvider = connectionProvider;
     _tableName          = tableName;
 }
Exemple #10
0
        /// <summary>
        /// Constructs the transport, connecting to the service bus pointed to by the connection string.
        /// </summary>
        public AzureServiceBusTransport(string connectionString, string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }
            if (asyncTaskFactory == null)
            {
                throw new ArgumentNullException(nameof(asyncTaskFactory));
            }

            _namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            _connectionString = connectionString;
            _asyncTaskFactory = asyncTaskFactory;
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            if (inputQueueAddress != null)
            {
                _inputQueueAddress = inputQueueAddress.ToLowerInvariant();
            }

            // if a timeout has been specified, we respect that - otherwise, we pick a sensible default:
            _receiveTimeout = _connectionString.Contains("OperationTimeout")
                ? default(TimeSpan?)
                              : TimeSpan.FromSeconds(5);
        }
Exemple #11
0
 public ReplyHandlerStep(ConcurrentDictionary<string, TimedMessage> messages, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, TimeSpan replyMaxAge)
 {
     _messages = messages;
     _replyMaxAge = replyMaxAge;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _cleanupTask = asyncTaskFactory.Create("CleanupAbandonedRepliesTask", CleanupAbandonedReplies);
 }
        /// <summary>
        /// Constructs the transport with the specified settings
        /// </summary>
        public AmazonSqsTransport(string inputQueueAddress, string accessKeyId, string secretAccessKey, RegionEndpoint regionEndpoint, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (accessKeyId == null) throw new ArgumentNullException("accessKeyId");
            if (secretAccessKey == null) throw new ArgumentNullException("secretAccessKey");
            if (regionEndpoint == null) throw new ArgumentNullException("regionEndpoint");
            if (rebusLoggerFactory == null) throw new ArgumentNullException("rebusLoggerFactory");

            _inputQueueAddress = inputQueueAddress;
            _log = rebusLoggerFactory.GetCurrentClassLogger();
            
            if (_inputQueueAddress != null)
            {
                if (_inputQueueAddress.Contains("/") && !Uri.IsWellFormedUriString(_inputQueueAddress, UriKind.Absolute))
                {
                    throw new ArgumentException(
                        "You could either have a simple queue name without slash (eg. \"inputqueue\") - or a complete URL for the queue endpoint. (eg. \"https://sqs.eu-central-1.amazonaws.com/234234234234234/somqueue\")",
                        "inputQueueAddress");
                }
            }

            _accessKeyId = accessKeyId;
            _secretAccessKey = secretAccessKey;
            _regionEndpoint = regionEndpoint;
            _rebusLoggerFactory = rebusLoggerFactory;
        }
 /// <summary>
 /// Constructs the saga storage
 /// </summary>
 public PostgreSqlSagaStorage(PostgresConnectionHelper connectionHelper, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
 {
     _connectionHelper = connectionHelper;
     _dataTableName    = dataTableName;
     _indexTableName   = indexTableName;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the subscription storage, storing subscriptions in the specified <paramref name="tableName"/>.
 /// If <paramref name="isCentralized"/> is true, subscribing/unsubscribing will be short-circuited by manipulating
 /// subscriptions directly, instead of requesting via messages
 /// </summary>
 public PostgreSqlSubscriptionStorage(PostgresConnectionHelper connectionHelper, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     _connectionHelper = connectionHelper;
     _tableName = tableName;
     IsCentralized = isCentralized;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription
 /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true
 /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests
 /// </summary>
 public SqlServerSubscriptionStorage(IDbConnectionProvider connectionProvider, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     IsCentralized = isCentralized;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _connectionProvider = connectionProvider;
     _tableName = tableName;
 }
 /// <summary>
 /// Constructs the step, using the specified transport to send the messages
 /// </summary>
 public SendOutgoingMessageStep(ITransport transport, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (transport == null) throw new ArgumentNullException(nameof(transport));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _transport = transport;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #17
0
        /// <summary>
        /// Constructs the saga storage, using the specified connection provider and tables for persistence.
        /// </summary>
		public SqlServerSagaStorage(IDbConnectionProvider connectionProvider, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
        {
            _log = rebusLoggerFactory.GetCurrentClassLogger();
            _connectionProvider = connectionProvider;
            _dataTableName = dataTableName;
            _indexTableName = indexTableName;
        }
        /// <summary>
        /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages
        /// and the specified <see cref="ITransport"/> to deliver messages when they're due.
        /// </summary>
        public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            if (timeoutManager == null)
            {
                throw new ArgumentNullException(nameof(timeoutManager));
            }
            if (transport == null)
            {
                throw new ArgumentNullException(nameof(transport));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }
            if (asyncTaskFactory == null)
            {
                throw new ArgumentNullException(nameof(asyncTaskFactory));
            }

            _timeoutManager = timeoutManager;
            _transport      = transport;
            _options        = options;
            _log            = rebusLoggerFactory.GetCurrentClassLogger();

            var dueTimeoutsPollIntervalSeconds = (int)options.DueTimeoutsPollInterval.TotalSeconds;
            var intervalToUse = dueTimeoutsPollIntervalSeconds >= 1 ? dueTimeoutsPollIntervalSeconds : 1;

            _dueMessagesSenderBackgroundTask = asyncTaskFactory.Create(DueMessagesSenderTaskName, TimerElapsed, intervalSeconds: intervalToUse);
        }
 /// <summary>
 /// Constructs the step, using the given transport and settings
 /// </summary>
 public SimpleRetryStrategyStep(ITransport transport, SimpleRetryStrategySettings simpleRetryStrategySettings, IErrorTracker errorTracker, IRebusLoggerFactory rebusLoggerFactory)
 {
     _transport = transport;
     _simpleRetryStrategySettings = simpleRetryStrategySettings;
     _errorTracker = errorTracker;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
        /// <summary>
        /// Creates the worker factory
        /// </summary>
        public ThreadPoolWorkerFactory(ITransport transport, IRebusLoggerFactory rebusLoggerFactory, IPipeline pipeline, IPipelineInvoker pipelineInvoker, Options options, Func<RebusBus> busGetter, BusLifetimeEvents busLifetimeEvents, ISyncBackoffStrategy backoffStrategy)
        {
            if (transport == null) throw new ArgumentNullException(nameof(transport));
            if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
            if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
            if (pipelineInvoker == null) throw new ArgumentNullException(nameof(pipelineInvoker));
            if (options == null) throw new ArgumentNullException(nameof(options));
            if (busGetter == null) throw new ArgumentNullException(nameof(busGetter));
            if (busLifetimeEvents == null) throw new ArgumentNullException(nameof(busLifetimeEvents));
            if (backoffStrategy == null) throw new ArgumentNullException(nameof(backoffStrategy));
            _transport = transport;
            _rebusLoggerFactory = rebusLoggerFactory;
            _pipeline = pipeline;
            _pipelineInvoker = pipelineInvoker;
            _options = options;
            _busGetter = busGetter;
            _backoffStrategy = backoffStrategy;
            _parallelOperationsManager = new ParallelOperationsManager(options.MaxParallelism);
            _log = _rebusLoggerFactory.GetCurrentClassLogger();

            if (_options.MaxParallelism < 1)
            {
                throw new ArgumentException($"Max parallelism is {_options.MaxParallelism} which is an invalid value");
            }

            if (options.WorkerShutdownTimeout < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException($"Cannot use '{options.WorkerShutdownTimeout}' as worker shutdown timeout as it");
            }

            busLifetimeEvents.WorkersStopped += WaitForContinuationsToFinish;
        }
Exemple #21
0
        /// <summary>
        /// Constructs the transport with a connection to the RabbitMQ instance specified by the given connection string
        /// </summary>
        public RabbitMqTransport(string connectionString, string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory)
        {
            _connectionManager = new ConnectionManager(connectionString, inputQueueAddress, rebusLoggerFactory);
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            Address = inputQueueAddress;
        }
        /// <summary>
        /// Constructs the transport with the specified settings
        /// </summary>
        public AmazonSqsTransport(string inputQueueAddress, string accessKeyId, string secretAccessKey, AmazonSQSConfig amazonSqsConfig, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            if (accessKeyId == null) throw new ArgumentNullException(nameof(accessKeyId));
            if (secretAccessKey == null) throw new ArgumentNullException(nameof(secretAccessKey));
            if (amazonSqsConfig == null) throw new ArgumentNullException(nameof(amazonSqsConfig));
            if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));

            Address = inputQueueAddress;

            _log = rebusLoggerFactory.GetCurrentClassLogger();

            if (Address != null)
            {
                if (Address.Contains("/") && !Uri.IsWellFormedUriString(Address, UriKind.Absolute))
                {
                    throw new ArgumentException(
                        "You could either have a simple queue name without slash (eg. \"inputqueue\") - or a complete URL for the queue endpoint. (eg. \"https://sqs.eu-central-1.amazonaws.com/234234234234234/somqueue\")",
                        nameof(inputQueueAddress));
                }
            }

            _accessKeyId = accessKeyId;
            _secretAccessKey = secretAccessKey;
            _amazonSqsConfig = amazonSqsConfig;
            _asyncTaskFactory = asyncTaskFactory;
        }
Exemple #23
0
        /// <summary>
        /// Constructs the transport with a connection to the RabbitMQ instance specified by the given connection string
        /// </summary>
        public RabbitMqTransport(string connectionString, string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory)
        {
            _connectionManager = new ConnectionManager(connectionString, inputQueueAddress, rebusLoggerFactory);
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            Address = inputQueueAddress;
        }
 /// <summary>
 /// Creates the saga storage using the given <paramref name="basePath"/> 
 /// </summary>
 public FileSystemSagaStorage(string basePath, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (basePath == null) throw new ArgumentNullException(nameof(basePath));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _basePath = basePath;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _lockFile = Path.Combine(basePath, "lock.txt");
 }
Exemple #25
0
 /// <summary>
 /// Constructs the in-mem error tracker with the configured number of delivery attempts as the MAX
 /// </summary>
 public InMemErrorTracker(int maxDeliveryAttempts, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
 {
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     if (asyncTaskFactory == null) throw new ArgumentNullException(nameof(asyncTaskFactory));
     _maxDeliveryAttempts = maxDeliveryAttempts;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _cleanupOldTrackedErrorsTask = asyncTaskFactory.Create(BackgroundTaskName, CleanupOldTrackedErrors, intervalSeconds: 60);
 }
Exemple #26
0
 /// <summary>
 /// Constructs the periodic background task with the given <paramref name="description"/>, periodically executing the given <paramref name="action"/>,
 /// waiting <see cref="Interval"/> between invocations.
 /// </summary>
 public TplAsyncTask(string description, Func <Task> action, IRebusLoggerFactory rebusLoggerFactory, bool prettyInsignificant)
 {
     _description         = description;
     _action              = action;
     _prettyInsignificant = prettyInsignificant;
     _log     = rebusLoggerFactory.GetCurrentClassLogger();
     Interval = DefaultInterval;
 }
 /// <summary>
 /// Creates the timeout manager, storing timeouts in the given <paramref name="basePath"/>
 /// </summary>
 public FilesystemTimeoutManager(string basePath, IRebusLoggerFactory loggerFactory)
 {
     if (basePath == null) throw new ArgumentNullException(nameof(basePath));
     if (loggerFactory == null) throw new ArgumentNullException(nameof(loggerFactory));
     _basePath = basePath;
     _lockFile = Path.Combine(basePath, "lock.txt");
     _log = loggerFactory.GetCurrentClassLogger();
 }
        /// <summary>
        /// Constructs the snapshot storage which will write saga data snapshots to files using file names on the form "ID-REVISION.json"
        /// </summary>
        public FileSystemSagaSnapshotStorage(string snapshotDirectory, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (snapshotDirectory == null) throw new ArgumentNullException("snapshotDirectory");
            if (rebusLoggerFactory == null) throw new ArgumentNullException("rebusLoggerFactory");

            _snapshotDirectory = snapshotDirectory;
            _log = rebusLoggerFactory.GetCurrentClassLogger();
        }
Exemple #29
0
        public void EnsureCreated()
        {
            _loggerFactory.GetCurrentClassLogger().Info("Auto creating table {0}", _tableName);
            var client = _cloudStorageAccount.CreateCloudTableClient();
            var t      = client.GetTableReference(_tableName);

            t.CreateIfNotExists();
        }
 /// <summary>
 /// Constructs the subscription storage using the specified document store. Can be configured to be centralized
 /// </summary>
 public RavenDbSubscriptionStorage(IDocumentStore documentStore, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (documentStore == null) throw new ArgumentNullException(nameof(documentStore));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _documentStore = documentStore;
     IsCentralized = isCentralized;
     _logger = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #31
0
 /// <summary>
 /// Constructs the periodic background task with the given <paramref name="description"/>, periodically executing the given <paramref name="action"/>,
 /// waiting <see cref="Interval"/> between invocations.
 /// </summary>
 public AsyncTask(string description, Func<Task> action, IRebusLoggerFactory rebusLoggerFactory, bool prettyInsignificant = false)
 {
     _description = description;
     _action = action;
     _prettyInsignificant = prettyInsignificant;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     Interval = DefaultInterval;
 }
 /// <summary>
 /// Creates the data bus storage
 /// </summary>
 public AzureBlobsDataBusStorage(CloudStorageAccount storageAccount, string containerName, IRebusLoggerFactory loggerFactory)
 {
     if (storageAccount == null) throw new ArgumentNullException(nameof(storageAccount));
     if (containerName == null) throw new ArgumentNullException(nameof(containerName));
     if (loggerFactory == null) throw new ArgumentNullException(nameof(loggerFactory));
     _containerName = containerName.ToLowerInvariant();
     _client = storageAccount.CreateCloudBlobClient();
     _log = loggerFactory.GetCurrentClassLogger();
 }
Exemple #33
0
 /// <summary>
 /// Constructs the in-mem error tracker with the configured number of delivery attempts as the MAX
 /// </summary>
 public InMemErrorTracker(int maxDeliveryAttempts, IRebusLoggerFactory rebusLoggerFactory)
 {
     _maxDeliveryAttempts = maxDeliveryAttempts;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _cleanupOldTrackedErrorsTask = new AsyncTask(BackgroundTaskName, CleanupOldTrackedErrors, rebusLoggerFactory)
     {
         Interval = TimeSpan.FromMinutes(1)
     };
 }
        /// <summary>
        /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages
        /// and the specified <see cref="ITransport"/> to deliver messages when they're due.
        /// </summary>
        public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            _timeoutManager = timeoutManager;
            _transport = transport;
            _options = options;
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            _dueMessagesSenderBackgroundTask = asyncTaskFactory.Create(DueMessagesSenderTaskName, TimerElapsed, intervalSeconds: 1);
        }
 /// <summary>
 /// Constructs the timeout manager
 /// </summary>
 public PostgreSqlTimeoutManager(PostgresConnectionHelper connectionHelper, string tableName, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (connectionHelper == null) throw new ArgumentNullException(nameof(connectionHelper));
     if (tableName == null) throw new ArgumentNullException(nameof(tableName));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _connectionHelper = connectionHelper;
     _tableName = tableName;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #36
0
        /// <summary>
        /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages
        /// and the specified <see cref="ITransport"/> to deliver messages when they're due.
        /// </summary>
        public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            _timeoutManager = timeoutManager;
            _transport      = transport;
            _options        = options;
            _log            = rebusLoggerFactory.GetCurrentClassLogger();

            _dueMessagesSenderBackgroundTask = asyncTaskFactory.Create(DueMessagesSenderTaskName, TimerElapsed, intervalSeconds: 1);
        }
Exemple #37
0
        public RebusWebHost(IRebusLoggerFactory rebusLoggerFactory)
        {
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            _logger = rebusLoggerFactory.GetCurrentClassLogger();
        }
 /// <summary>
 /// Constructs the in-mem error tracker with the configured number of delivery attempts as the MAX
 /// </summary>
 public InMemErrorTracker(int maxDeliveryAttempts, IRebusLoggerFactory rebusLoggerFactory)
 {
     _maxDeliveryAttempts = maxDeliveryAttempts;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _cleanupOldTrackedErrorsTask = new AsyncTask(BackgroundTaskName, CleanupOldTrackedErrors, rebusLoggerFactory)
     {
         Interval = TimeSpan.FromMinutes(1)
     };
 }
 /// <summary>
 /// Creates the error handler
 /// </summary>
 public PoisonQueueErrorHandler(SimpleRetryStrategySettings simpleRetryStrategySettings, ITransport transport, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (simpleRetryStrategySettings == null) throw new ArgumentNullException(nameof(simpleRetryStrategySettings));
     if (transport == null) throw new ArgumentNullException(nameof(transport));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _simpleRetryStrategySettings = simpleRetryStrategySettings;
     _transport = transport;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 public ForwardOnExceptionsStep(Type exceptionType, string destinationQueue, ITransport transport, IRebusLoggerFactory rebusLoggerFactory, LogLevel logLevel, Func <Exception, bool> shouldForward)
 {
     _logger           = rebusLoggerFactory.GetCurrentClassLogger();
     _exceptionType    = exceptionType;
     _destinationQueue = destinationQueue;
     _transport        = transport;
     _logLevel         = logLevel;
     _shouldForward    = shouldForward;
 }
        /// <summary>
        /// Creates the storage
        /// </summary>
        public AzureStorageSagaSnapshotStorage(CloudStorageAccount storageAccount, IRebusLoggerFactory loggerFactory, string containerName = "RebusSagaStorage")
        {
            if (storageAccount == null) throw new ArgumentNullException(nameof(storageAccount));
            if (loggerFactory == null) throw new ArgumentNullException(nameof(loggerFactory));

            _log = loggerFactory.GetCurrentClassLogger();
            _container = storageAccount.CreateCloudBlobClient()
                .GetContainerReference(containerName.ToLowerInvariant());
        }
        /// <summary>
        /// Creates the worker factory
        /// </summary>
        public ThreadPoolWorkerFactory(ITransport transport, IRebusLoggerFactory rebusLoggerFactory, IPipeline pipeline, IPipelineInvoker pipelineInvoker, Options options, Func <RebusBus> busGetter, BusLifetimeEvents busLifetimeEvents, ISyncBackoffStrategy backoffStrategy)
        {
            if (transport == null)
            {
                throw new ArgumentNullException(nameof(transport));
            }
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }
            if (pipeline == null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }
            if (pipelineInvoker == null)
            {
                throw new ArgumentNullException(nameof(pipelineInvoker));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (busGetter == null)
            {
                throw new ArgumentNullException(nameof(busGetter));
            }
            if (busLifetimeEvents == null)
            {
                throw new ArgumentNullException(nameof(busLifetimeEvents));
            }
            if (backoffStrategy == null)
            {
                throw new ArgumentNullException(nameof(backoffStrategy));
            }
            _transport                 = transport;
            _rebusLoggerFactory        = rebusLoggerFactory;
            _pipeline                  = pipeline;
            _pipelineInvoker           = pipelineInvoker;
            _options                   = options;
            _busGetter                 = busGetter;
            _backoffStrategy           = backoffStrategy;
            _parallelOperationsManager = new ParallelOperationsManager(options.MaxParallelism);
            _log = _rebusLoggerFactory.GetCurrentClassLogger();

            if (_options.MaxParallelism < 1)
            {
                throw new ArgumentException($"Max parallelism is {_options.MaxParallelism} which is an invalid value");
            }

            if (options.WorkerShutdownTimeout < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException($"Cannot use '{options.WorkerShutdownTimeout}' as worker shutdown timeout as it");
            }

            busLifetimeEvents.WorkersStopped += WaitForContinuationsToFinish;
        }
Exemple #43
0
        /// <summary>
        /// Constructs the transport with a connection to the RabbitMQ instance specified by the given connection string
        /// </summary>
        public RabbitMqTransport(string connectionString, string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory, ushort maxMessagesToPrefetch = 50)
        {
            if (connectionString == null) throw new ArgumentNullException(nameof(connectionString));
            if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));

            _connectionManager = new ConnectionManager(connectionString, inputQueueAddress, rebusLoggerFactory);
            _maxMessagesToPrefetch = maxMessagesToPrefetch;
            _log = rebusLoggerFactory.GetCurrentClassLogger();
            Address = inputQueueAddress;
        }
        /// <summary>
        /// Uses provided SqlConnection factory as constructor for SqlConnection used. Will use <see cref="System.Data.IsolationLevel.ReadCommitted"/> by default on transactions,
        /// unless another isolation level is set with the <see cref="IsolationLevel"/> property
        /// </summary>
        public DbConnectionFactoryProvider(Func<Task<IDbConnection>> connectionFactory, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));

            _log = rebusLoggerFactory.GetCurrentClassLogger();

            IsolationLevel = IsolationLevel.ReadCommitted;

            _connectionFactory = connectionFactory;
        }
 /// <summary>
 /// Creates the data storage
 /// </summary>
 public SqlServerDataBusStorage(IDbConnectionProvider connectionProvider, string tableName, bool ensureTableIsCreated, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (connectionProvider == null) throw new ArgumentNullException(nameof(connectionProvider));
     if (tableName == null) throw new ArgumentNullException(nameof(tableName));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _connectionProvider = connectionProvider;
     _tableName = tableName;
     _ensureTableIsCreated = ensureTableIsCreated;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the saga storage
 /// </summary>
 public PostgreSqlSagaStorage(PostgresConnectionHelper connectionHelper, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (connectionHelper == null) throw new ArgumentNullException(nameof(connectionHelper));
     if (dataTableName == null) throw new ArgumentNullException(nameof(dataTableName));
     if (indexTableName == null) throw new ArgumentNullException(nameof(indexTableName));
     if (rebusLoggerFactory == null) throw new ArgumentNullException(nameof(rebusLoggerFactory));
     _connectionHelper = connectionHelper;
     _dataTableName = dataTableName;
     _indexTableName = indexTableName;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #47
0
        /// <summary>
        /// Constructs the transport with the specified input queue address
        /// </summary>
        public MsmqTransport(string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (rebusLoggerFactory == null) throw new ArgumentNullException("rebusLoggerFactory");

            _log = rebusLoggerFactory.GetCurrentClassLogger();

            if (inputQueueAddress != null)
            {
                _inputQueueName = MakeGloballyAddressable(inputQueueAddress);
            }
        }
Exemple #48
0
        /// <summary>
        /// Constructs the transport with the given <see cref="IDbConnectionProvider"/>, using the specified <paramref name="tableName"/> to send/receive messages,
        /// querying for messages with recipient = <paramref name="inputQueueName"/>
        /// </summary>
        public SqlServerTransport(IDbConnectionProvider connectionProvider, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
        {
            _connectionProvider = connectionProvider;
            _tableName          = tableName;
            _inputQueueName     = inputQueueName;
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval;

            _expiredMessagesCleanupTask = asyncTaskFactory.Create("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, intervalSeconds: 60);
        }
Exemple #49
0
 /// <summary>
 /// Constructs the bus.
 /// </summary>
 public RebusBus(IWorkerFactory workerFactory, IRouter router, ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, ISubscriptionStorage subscriptionStorage, Options options, IRebusLoggerFactory rebusLoggerFactory)
 {
     _workerFactory       = workerFactory;
     _router              = router;
     _transport           = transport;
     _pipeline            = pipeline;
     _pipelineInvoker     = pipelineInvoker;
     _subscriptionStorage = subscriptionStorage;
     _options             = options;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #50
0
        /// <summary>
        /// Constructs the step, using the specified <see cref="ITimeoutManager"/> to defer relevant messages
        /// and the specified <see cref="ITransport"/> to deliver messages when they're due.
        /// </summary>
        public HandleDeferredMessagesStep(ITimeoutManager timeoutManager, ITransport transport, Options options, IRebusLoggerFactory rebusLoggerFactory)
        {
            _timeoutManager = timeoutManager;
            _transport      = transport;
            _options        = options;
            _log            = rebusLoggerFactory.GetCurrentClassLogger();

            _dueMessagesSenderBackgroundTask = new AsyncTask(DueMessagesSenderTaskName, TimerElapsed, rebusLoggerFactory)
            {
                Interval = TimeSpan.FromSeconds(1)
            };
        }
        /// <summary>
        /// Uses provided SqlConnection factory as constructor for SqlConnection used. Will use <see cref="System.Data.IsolationLevel.ReadCommitted"/> by default on transactions,
        /// unless another isolation level is set with the <see cref="IsolationLevel"/> property
        /// </summary>
        public DbConnectionFactoryProvider(Func <Task <IDbConnection> > connectionFactory, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            _log = rebusLoggerFactory.GetCurrentClassLogger();

            IsolationLevel = IsolationLevel.ReadCommitted;

            _connectionFactory = connectionFactory;
        }
 /// <summary>
 /// Creates the data storage
 /// </summary>
 public FileSystemDataBusStorage(string directoryPath, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (directoryPath == null)
     {
         throw new ArgumentNullException(nameof(directoryPath));
     }
     if (rebusLoggerFactory == null)
     {
         throw new ArgumentNullException(nameof(rebusLoggerFactory));
     }
     _directoryPath = directoryPath;
     _log           = rebusLoggerFactory.GetCurrentClassLogger();
 }
 /// <summary>
 /// Constructs the step with the given saga storage
 /// </summary>
 public LoadSagaDataStep(ISagaStorage sagaStorage, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (sagaStorage == null)
     {
         throw new ArgumentNullException(nameof(sagaStorage));
     }
     if (rebusLoggerFactory == null)
     {
         throw new ArgumentNullException(nameof(rebusLoggerFactory));
     }
     _sagaStorage = sagaStorage;
     _log         = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #54
0
 /// <summary>
 /// Constructs the step, using the specified transport to send the messages
 /// </summary>
 public SendOutgoingMessageStep(ITransport transport, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (transport == null)
     {
         throw new ArgumentNullException(nameof(transport));
     }
     if (rebusLoggerFactory == null)
     {
         throw new ArgumentNullException(nameof(rebusLoggerFactory));
     }
     _transport = transport;
     _log       = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #55
0
 /// <summary>
 /// Constructs the subscription storage using the specified document store. Can be configured to be centralized
 /// </summary>
 public RavenDbSubscriptionStorage(IDocumentStore documentStore, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (documentStore == null)
     {
         throw new ArgumentNullException(nameof(documentStore));
     }
     if (rebusLoggerFactory == null)
     {
         throw new ArgumentNullException(nameof(rebusLoggerFactory));
     }
     _documentStore = documentStore;
     IsCentralized  = isCentralized;
     _logger        = rebusLoggerFactory.GetCurrentClassLogger();
 }
Exemple #56
0
        /// <summary>
        /// Constructs the transport with the given <see cref="IDbConnectionProvider"/>, using the specified <paramref name="tableName"/> to send/receive messages,
        /// querying for messages with recipient = <paramref name="inputQueueName"/>
        /// </summary>
        public SqlServerTransport(IDbConnectionProvider connectionProvider, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory)
        {
            _connectionProvider = connectionProvider;
            _tableName          = tableName;
            _inputQueueName     = inputQueueName;
            _log = rebusLoggerFactory.GetCurrentClassLogger();

            ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval;

            _expiredMessagesCleanupTask = new AsyncTask("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, rebusLoggerFactory)
            {
                Interval = TimeSpan.FromMinutes(1)
            };
        }
Exemple #57
0
        /// <summary>
        /// Constructs the transport with the specified input queue address
        /// </summary>
        public MsmqTransport(string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            _log = rebusLoggerFactory.GetCurrentClassLogger();

            if (inputQueueAddress != null)
            {
                _inputQueueName = MakeGloballyAddressable(inputQueueAddress);
            }
        }
Exemple #58
0
 /// <summary>
 /// Creates the saga storage using the given <paramref name="basePath"/>
 /// </summary>
 public FileSystemSagaStorage(string basePath, IRebusLoggerFactory rebusLoggerFactory)
 {
     if (basePath == null)
     {
         throw new ArgumentNullException(nameof(basePath));
     }
     if (rebusLoggerFactory == null)
     {
         throw new ArgumentNullException(nameof(rebusLoggerFactory));
     }
     _basePath = basePath;
     _log      = rebusLoggerFactory.GetCurrentClassLogger();
     _lockFile = Path.Combine(basePath, "lock.txt");
 }
Exemple #59
0
 /// <summary>
 /// Constructs the in-mem error tracker with the configured number of delivery attempts as the MAX
 /// </summary>
 public InMemErrorTracker(int maxDeliveryAttempts, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory)
 {
     if (rebusLoggerFactory == null)
     {
         throw new ArgumentNullException(nameof(rebusLoggerFactory));
     }
     if (asyncTaskFactory == null)
     {
         throw new ArgumentNullException(nameof(asyncTaskFactory));
     }
     _maxDeliveryAttempts = maxDeliveryAttempts;
     _log = rebusLoggerFactory.GetCurrentClassLogger();
     _cleanupOldTrackedErrorsTask = asyncTaskFactory.Create(BackgroundTaskName, CleanupOldTrackedErrors, intervalSeconds: 60);
 }
Exemple #60
0
        /// <summary>
        /// Constructs the snapshot storage which will write saga data snapshots to files using file names on the form "ID-REVISION.json"
        /// </summary>
        public FileSystemSagaSnapshotStorage(string snapshotDirectory, IRebusLoggerFactory rebusLoggerFactory)
        {
            if (snapshotDirectory == null)
            {
                throw new ArgumentNullException(nameof(snapshotDirectory));
            }
            if (rebusLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(rebusLoggerFactory));
            }

            _snapshotDirectory = snapshotDirectory;
            _log = rebusLoggerFactory.GetCurrentClassLogger();
        }