public PostgreSqlTaskQueueConsumer(TaskQueueConsumerOptions options, ITimestampProvider timestampProvider) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (timestampProvider == null) { throw new ArgumentNullException(nameof(timestampProvider)); } mOptions = options; mTimestampProvider = timestampProvider; mSignalingConnectionString = options.ConnectionOptions .ConnectionString .DeriveSignalingConnectionString(options); mNotificationListener = new PostgreSqlTaskQueueNotificationListener(mSignalingConnectionString, options.Mapping.NewTaskNotificationChannelName); mNotificationListener.ListenerConnectionRestored += HandleListenerConnectionRestored; mNotificationListener.NewTaskPosted += HandleNewTaskUpdateReceived; mNotificationListener.ListenerTimedOutWhileWaiting += HandleListenerTimedOut; mTaskDequeueSql = GetTaskDequeueSql(options.Mapping); mTaskAcquireSql = GetTaskAcquireSql(options.Mapping); mTaskResultUpdateSql = GetTaskResultUpdateSql(options.Mapping); }
public PostgreSqlTaskQueueConsumerTests() { mConsumerOptions = TestOptions .GetDefaultTaskQueueConsumerOptions(ConnectionString); mDataSource = new PostgreSqlTaskQueueDataSource(mConsumerOptions.ConnectionOptions.ConnectionString, TestOptions.DefaultMapping, queueFaultErrorThrehsoldCount: 5); }
public PostgreSqlTaskQueueOperationsConsistencyTests() { mInfoOptions = TestOptions .GetDefaultTaskQueueInfoOptions(ConnectionString); mConsumerOptions = TestOptions .GetDefaultTaskQueueConsumerOptions(ConnectionString); mProducerOptions = TestOptions .GetDefaultTaskQueueProducerAndResultOptions(ConnectionString); mDataSource = new PostgreSqlTaskQueueDataSource(mInfoOptions.ConnectionOptions.ConnectionString, TestOptions.DefaultMapping, queueFaultErrorThrehsoldCount: 5); }
public StandardTaskEngine(TaskEngineOptions engineOptions, TaskQueueOptions producerAndResultOptions, TaskQueueConsumerOptions consumerOptions, ITaskExecutorRegistry executorRegistry, IExecutionPerformanceMonitorWriter executionPerfMonWriter, ITimestampProvider timestampProvider) { if (engineOptions == null) { throw new ArgumentNullException(nameof(engineOptions)); } if (consumerOptions == null) { throw new ArgumentNullException(nameof(consumerOptions)); } if (producerAndResultOptions == null) { throw new ArgumentNullException(nameof(producerAndResultOptions)); } mExecutorRegistry = executorRegistry ?? throw new ArgumentNullException(nameof(executorRegistry)); mExecutionPerfMonWriter = executionPerfMonWriter ?? throw new ArgumentNullException(nameof(executionPerfMonWriter)); mExecutionPerfMon = new StandardExecutionPerformanceMonitor(); mTaskQueueConsumer = new PostgreSqlTaskQueueConsumer(consumerOptions, timestampProvider); mTaskQueueProducer = new PostgreSqlTaskQueueProducer(producerAndResultOptions, timestampProvider); mTaskResultQueue = new PostgreSqlTaskResultQueue(producerAndResultOptions); mTaskBuffer = new StandardTaskBuffer(engineOptions.WorkerCount); mTaskPoller = new StandardTaskPoller(engineOptions.TaskProcessingOptions, mTaskQueueConsumer, mTaskBuffer); mOptions = engineOptions; }
public WorkingTests() { mTimestampProvider = new UtcNowTimestampProvider(); mTaskProcessingOptions = TestOptions .GetDefaultTaskProcessingOptions(); mProducerAndResultOptions = TestOptions .GetDefaultTaskQueueProducerAndResultOptions(CommonConnectionString); mTaskQueueConsumerOptions = TestOptions .GetDefaultTaskQueueConsumerOptions(BaseConsumerConnectionString); mPostgreSqlExecutionPerformanceMonitorWriterOptions = TestOptions .GetDefaultPostgreSqlExecutionPerformanceMonitorWriterOptions(CommonConnectionString); mOperations = new PostgreSqlTaskQueueDbOperations(CommonConnectionString, TestOptions.DefaultMapping); }
public ITaskEngine BuildTaskEngine() { ITaskExecutorRegistry executorRegistry = mTaskExecutorRegistrySetup .BuildTaskExecutorRegistry(); IExecutionPerformanceMonitorWriter executionPerfMonWriter = mPerformanceMonitorWriterSetup .BuildWriter(); ITimestampProvider timestampProvider = new UtcNowTimestampProvider(); TaskQueueConsumerOptions consumerOptions = mTaskQueueConsumerSetup .BuildOptions(); TaskQueueOptions producerOptions = mTaskQueueProducerSetup .BuildOptions(); StakhanoviseLogManager.Provider = mLoggingProvider ?? new NoOpLoggingProvider(); ITaskQueueProducer taskQueueProducer = new PostgreSqlTaskQueueProducer(producerOptions, timestampProvider); ITaskQueueInfo taskQueueInfo = new PostgreSqlTaskQueueInfo(mTaskQueueInfoSetup.BuildOptions(), timestampProvider); if (mRegisterOwnDependencies) { executorRegistry.LoadDependencies(new Dictionary <Type, object>() { { typeof(ITaskQueueProducer), taskQueueProducer }, { typeof(ITaskQueueInfo), taskQueueInfo } }); } return(mTaskEngineSetup.BuildTaskEngine(consumerOptions, producerOptions, executorRegistry, executionPerfMonWriter, timestampProvider)); }
public ITaskEngine BuildTaskEngine(TaskQueueConsumerOptions consumerOptions, TaskQueueOptions producerAndResultOptions, ITaskExecutorRegistry executorRegistry, IExecutionPerformanceMonitorWriter executionPerfMonWriter, ITimestampProvider timestampProvider) { if (consumerOptions == null) { throw new ArgumentNullException(nameof(consumerOptions)); } if (producerAndResultOptions == null) { throw new ArgumentNullException(nameof(producerAndResultOptions)); } if (executorRegistry == null) { throw new ArgumentNullException(nameof(executorRegistry)); } if (executionPerfMonWriter == null) { throw new ArgumentNullException(nameof(executionPerfMonWriter)); } StandardTaskEngine taskEngine = new StandardTaskEngine(BuildOptions(), producerAndResultOptions, consumerOptions, executorRegistry, executionPerfMonWriter, timestampProvider); taskEngine.ScanAssemblies(mExecutorAssemblies); return(taskEngine); }
public static string DeriveSignalingConnectionString(this NpgsqlConnectionStringBuilder info, TaskQueueConsumerOptions options) { if (info == null) { throw new ArgumentNullException(nameof(info)); } //The connection used for signaling will be // the same as the one used for read-only queue operation // with the notable exceptions that: // a) we need to activate the Npgsql keepalive mechanism (see: http://www.npgsql.org/doc/keepalive.html) // b) we do not need a large pool - one connection will do NpgsqlConnectionStringBuilder signalingConnectionStringInfo = info.Copy(); signalingConnectionStringInfo.Pooling = true; signalingConnectionStringInfo.MinPoolSize = 1; signalingConnectionStringInfo.MaxPoolSize = 2; signalingConnectionStringInfo.KeepAlive = options.ConnectionOptions.ConnectionKeepAliveSeconds; return(signalingConnectionStringInfo.ToString()); }
public static string DeriveSignalingConnectionString(this string connectionString, TaskQueueConsumerOptions options) { if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentNullException(nameof(connectionString)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } NpgsqlConnectionStringBuilder builder = new NpgsqlConnectionStringBuilder(connectionString); return(builder.DeriveSignalingConnectionString(options)); }