public MessageReceiver( SqlServerTransport transport, string receiverId, string receiveAddress, string errorQueueAddress, Action <string, Exception, CancellationToken> criticalErrorAction, Func <TransportTransactionMode, ProcessStrategy> processStrategyFactory, Func <string, TableBasedQueue> queueFactory, IPurgeQueues queuePurger, IExpiredMessagesPurger expiredMessagesPurger, IPeekMessagesInQueue queuePeeker, QueuePeekerOptions queuePeekerOptions, SchemaInspector schemaInspector, TimeSpan waitTimeCircuitBreaker, ISubscriptionManager subscriptionManager) { this.transport = transport; this.processStrategyFactory = processStrategyFactory; this.queuePurger = queuePurger; this.queueFactory = queueFactory; this.expiredMessagesPurger = expiredMessagesPurger; this.queuePeeker = queuePeeker; this.queuePeekerOptions = queuePeekerOptions; this.schemaInspector = schemaInspector; this.waitTimeCircuitBreaker = waitTimeCircuitBreaker; this.errorQueueAddress = errorQueueAddress; this.criticalErrorAction = criticalErrorAction; Subscriptions = subscriptionManager; Id = receiverId; ReceiveAddress = receiveAddress; }
public MessagePump(Func <TransportTransactionMode, ReceiveStrategy> receiveStrategyFactory, Func <string, TableBasedQueue> queueFactory, IPurgeQueues queuePurger, IExpiredMessagesPurger expiredMessagesPurger, IPeekMessagesInQueue queuePeeker, QueuePeekerOptions queuePeekerOptions, SchemaInspector schemaInspector, TimeSpan waitTimeCircuitBreaker) { this.receiveStrategyFactory = receiveStrategyFactory; this.queuePurger = queuePurger; this.queueFactory = queueFactory; this.expiredMessagesPurger = expiredMessagesPurger; this.queuePeeker = queuePeeker; this.queuePeekerOptions = queuePeekerOptions; this.schemaInspector = schemaInspector; this.waitTimeCircuitBreaker = waitTimeCircuitBreaker; }
public MessageReceiver(SqlServerTransport transport, ReceiveSettings receiveSettings, HostSettings hostSettings, Func <TransportTransactionMode, ProcessStrategy> processStrategyFactory, Func <string, TableBasedQueue> queueFactory, IPurgeQueues queuePurger, IExpiredMessagesPurger expiredMessagesPurger, IPeekMessagesInQueue queuePeeker, QueuePeekerOptions queuePeekerOptions, SchemaInspector schemaInspector, TimeSpan waitTimeCircuitBreaker, ISubscriptionManager subscriptionManager) { this.transport = transport; this.receiveSettings = receiveSettings; this.hostSettings = hostSettings; this.processStrategyFactory = processStrategyFactory; this.queuePurger = queuePurger; this.queueFactory = queueFactory; this.expiredMessagesPurger = expiredMessagesPurger; this.queuePeeker = queuePeeker; this.queuePeekerOptions = queuePeekerOptions; this.schemaInspector = schemaInspector; this.waitTimeCircuitBreaker = waitTimeCircuitBreaker; Subscriptions = subscriptionManager; }
public QueuePeeker(SqlConnectionFactory connectionFactory, QueuePeekerOptions settings) { this.connectionFactory = connectionFactory; this.settings = settings; }
public override TransportReceiveInfrastructure ConfigureReceiveInfrastructure() { if (!settings.TryGet(out SqlScopeOptions scopeOptions)) { scopeOptions = new SqlScopeOptions(); } settings.TryGet(out TransportTransactionMode transactionMode); diagnostics.Add("NServiceBus.Transport.SqlServer.Transactions", new { TransactionMode = transactionMode, scopeOptions.TransactionOptions.IsolationLevel, scopeOptions.TransactionOptions.Timeout }); if (!settings.TryGet(SettingsKeys.TimeToWaitBeforeTriggering, out TimeSpan waitTimeCircuitBreaker)) { waitTimeCircuitBreaker = TimeSpan.FromSeconds(30); } diagnostics.Add("NServiceBus.Transport.SqlServer.CircuitBreaker", new { TimeToWaitBeforeTriggering = waitTimeCircuitBreaker }); if (!settings.TryGet(out QueuePeekerOptions queuePeekerOptions)) { queuePeekerOptions = new QueuePeekerOptions(); } var createMessageBodyComputedColumn = settings.GetOrDefault <bool>(SettingsKeys.CreateMessageBodyComputedColumn); Func <TransportTransactionMode, ReceiveStrategy> receiveStrategyFactory = guarantee => SelectReceiveStrategy(guarantee, scopeOptions.TransactionOptions, connectionFactory); var queuePurger = new QueuePurger(connectionFactory); var queuePeeker = new QueuePeeker(connectionFactory, queuePeekerOptions); IExpiredMessagesPurger expiredMessagesPurger; bool validateExpiredIndex; if (settings.GetOrDefault <bool>(SettingsKeys.PurgeEnableKey)) { diagnostics.Add("NServiceBus.Transport.SqlServer.ExpiredMessagesPurger", new { Enabled = false, }); expiredMessagesPurger = new NoOpExpiredMessagesPurger(); validateExpiredIndex = false; } else { var purgeBatchSize = settings.HasSetting(SettingsKeys.PurgeBatchSizeKey) ? settings.Get <int?>(SettingsKeys.PurgeBatchSizeKey) : null; diagnostics.Add("NServiceBus.Transport.SqlServer.ExpiredMessagesPurger", new { Enabled = true, BatchSize = purgeBatchSize }); expiredMessagesPurger = new ExpiredMessagesPurger(_ => connectionFactory.OpenNewConnection(), purgeBatchSize); validateExpiredIndex = true; } var schemaVerification = new SchemaInspector(queue => connectionFactory.OpenNewConnection(), validateExpiredIndex); Func <string, TableBasedQueue> queueFactory = queueName => new TableBasedQueue(addressTranslator.Parse(queueName).QualifiedTableName, queueName, !isEncrypted); //Create delayed delivery infrastructure CanonicalQueueAddress delayedQueueCanonicalAddress = null; if (settings.GetOrDefault <bool>(SettingsKeys.DisableDelayedDelivery) == false) { if (!settings.TryGet(SettingsKeys.DelayedDeliverySuffix, out string suffix)) { suffix = "Delayed"; } if (!settings.TryGet(SettingsKeys.DelayedDeliveryInterval, out TimeSpan interval)) { interval = TimeSpan.FromSeconds(1); } if (!settings.TryGet(SettingsKeys.DelayedDeliveryMatureBatchSize, out int matureBatchSize)) { matureBatchSize = 100; } settings.AddStartupDiagnosticsSection("NServiceBus.Transport.SqlServer.DelayedDelivery", new { Native = true, Suffix = suffix, Interval = interval, BatchSize = matureBatchSize, }); delayedQueueCanonicalAddress = GetDelayedTableAddress(suffix); var inputQueueTable = addressTranslator.Parse(ToTransportAddress(logicalAddress())).QualifiedTableName; var delayedMessageTable = new DelayedMessageTable(delayedQueueCanonicalAddress.QualifiedTableName, inputQueueTable); //Allows dispatcher to store messages in the delayed store delayedMessageStore = delayedMessageTable; dueDelayedMessageProcessor = new DueDelayedMessageProcessor(delayedMessageTable, connectionFactory, interval, matureBatchSize); } return(new TransportReceiveInfrastructure( () => new MessagePump(receiveStrategyFactory, queueFactory, queuePurger, expiredMessagesPurger, queuePeeker, queuePeekerOptions, schemaVerification, waitTimeCircuitBreaker), () => new QueueCreator(connectionFactory, addressTranslator, delayedQueueCanonicalAddress, createMessageBodyComputedColumn), () => ValidateDatabaseAccess(scopeOptions.TransactionOptions))); }