public static StartupCheckResult Check(bool usingMsmq, bool isTransactional, bool outBoxRunning, bool auditTTBROverridden, bool forwardTTBROverridden) { if (!usingMsmq) { return(StartupCheckResult.Success); } if (!isTransactional) { return(StartupCheckResult.Success); } if (outBoxRunning) { return(StartupCheckResult.Success); } if (auditTTBROverridden) { return(StartupCheckResult.Failed("Setting a custom OverrideTimeToBeReceived for audits is not supported on transactional MSMQ.")); } if (forwardTTBROverridden) { return(StartupCheckResult.Failed("Setting a custom TimeToBeReceivedOnForwardedMessages is not supported on transactional MSMQ.")); } return(StartupCheckResult.Success); }
async Task <StartupCheckResult> CheckForAmbientTransactionEnlistmentSupport(SqlConnectionFactory connectionFactory, TransactionOptions transactionOptions) { if (!settings.TryGet(out TransportTransactionMode requestedTransportTransactionMode)) { requestedTransportTransactionMode = TransactionMode; } if (requestedTransportTransactionMode == TransportTransactionMode.TransactionScope) { try { using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOptions, TransactionScopeAsyncFlowOption.Enabled)) using (await connectionFactory.OpenNewConnection().ConfigureAwait(false)) { scope.Complete(); } } catch (NotSupportedException) { var message = "The version of System.Data.SqlClient in use does not support enlisting SQL connections in ambient transactions, so the TransactionScope transport transaction mode cannot be used. Use `EndpointConfiguration.UseTransport<SqlServerTransport>().Transactions` to select a different transport transaction mode."; return(StartupCheckResult.Failed(message)); } } return(StartupCheckResult.Success); }
public static StartupCheckResult Check() { var timeToWaitBeforeTriggering = ConfigurationManager.AppSettings["NServiceBus/RabbitMqDequeueStrategy/TimeToWaitBeforeTriggering"]; if (timeToWaitBeforeTriggering != null) { var message = "The 'TimeToWaitBeforeTriggering' configuration setting has been removed. Use 'EndpointConfiguration.UseTransport<RabbitMQTransport>().TimeToWaitBeforeTriggeringCircuitBreaker' instead."; Logger.Error(message); return(StartupCheckResult.Failed(message)); } var delayAfterFailure = ConfigurationManager.AppSettings["NServiceBus/RabbitMqDequeueStrategy/DelayAfterFailure"]; if (delayAfterFailure != null) { var message = "The 'DelayAfterFailure' configuration setting has been removed. Consult the documentation for further information."; Logger.Error(message); return(StartupCheckResult.Failed(message)); } return(StartupCheckResult.Success); }
async Task <StartupCheckResult> CheckForAmbientTransactionEnlistmentSupport(TransactionOptions transactionOptions) { if (!settings.TryGet(out TransportTransactionMode requestedTransportTransactionMode)) { requestedTransportTransactionMode = TransactionMode; } if (requestedTransportTransactionMode == TransportTransactionMode.TransactionScope) { try { using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOptions, TransactionScopeAsyncFlowOption.Enabled)) using (await connectionFactory.OpenNewConnection().ConfigureAwait(false)) { scope.Complete(); } } catch (NotSupportedException ex) { var message = "The version of System.Data.SqlClient in use does not support one of the selected connection string options or " + "enlisting SQL connections in distributed transactions. Check original error message for details. " + "In case the problem is related to distributed transactions you can still use SQL Server transport but " + "specify a different transaction mode via `EndpointConfiguration.UseTransport<SqlServerTransport>().Transactions`. " + "Note that different transaction modes may affect consistency guarantees as you can't rely on distributed " + "transactions to atomically update the database and consume a message. Original error message: " + ex.Message; return(StartupCheckResult.Failed(message)); } } return(StartupCheckResult.Success); }
public static StartupCheckResult CheckForInvalidSettings(SettingsHolder settings) { var routingTopologySupportsDelayedDelivery = settings.GetOrDefault <bool>(SettingsKeys.RoutingTopologySupportsDelayedDelivery); var timeoutManagerDisabled = settings.GetOrDefault <bool>(SettingsKeys.DisableTimeoutManager); var externalTimeoutManagerAddress = settings.GetOrDefault <string>(coreExternalTimeoutManagerAddressKey) != null; var timeoutManagerFeatureActive = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Active; if (!routingTopologySupportsDelayedDelivery && timeoutManagerDisabled) { return(StartupCheckResult.Failed($"Cannot disable the timeout manager when the specified routing topology does not implement {nameof(ISupportDelayedDelivery)}.")); } if (routingTopologySupportsDelayedDelivery) { if (externalTimeoutManagerAddress) { return(StartupCheckResult.Failed("An external timeout manager address cannot be configured because the timeout manager is not being used for delayed delivery.")); } if (!timeoutManagerDisabled && !timeoutManagerFeatureActive) { return(StartupCheckResult.Failed("The timeout manager is not active, but the transport has not been properly configured for this. " + "Use 'EndpointConfiguration.UseTransport<RabbitMQTransport>().DelayedDelivery().DisableTimeoutManager()' to ensure delayed messages can be sent properly.")); } } return(StartupCheckResult.Success); }
public static StartupCheckResult CheckForInvalidSetting(bool routingTopologySupportsDelayedDelivery, bool disableTimeoutManager) { if (!routingTopologySupportsDelayedDelivery && disableTimeoutManager) { return(StartupCheckResult.Failed($"Cannot disable the timeout manager when the specified routing topology does not implement {nameof(ISupportDelayedDelivery)}.")); } return(StartupCheckResult.Success); }
async Task CheckForManagePermissions() { if (startupCheckResult == null) { startupCheckResult = await namespacePermissions.CanManage().ConfigureAwait(false); } if (!startupCheckResult.Succeeded) { throw new Exception(startupCheckResult.ErrorMessage); } }
public static StartupCheckResult CheckForInvalidSettings(SettingsHolder settings) { var timeoutManagerShouldBeEnabled = settings.GetOrDefault <bool>(SettingsKeys.EnableTimeoutManager); var timeoutManagerFeatureActive = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Active; if (timeoutManagerShouldBeEnabled && !timeoutManagerFeatureActive) { return(StartupCheckResult.Failed("The transport has been configured to enable the timeout manager, but the timeout manager is not active." + "Ensure that the timeout manager is active or remove the call to 'EndpointConfiguration.UseTransport<RabbitMQTransport>().DelayedDelivery().EnableTimeoutManager()'.")); } return(StartupCheckResult.Success); }
public static StartupCheckResult CheckForInvalidSettings(ReadOnlySettings settings) { var timeoutManagerFeatureActive = settings.IsFeatureActive(typeof(TimeoutManager)); var timeoutManagerShouldBeEnabled = settings.GetOrDefault <bool>(WellKnownConfigurationKeys.DelayedDelivery.EnableTimeoutManager); if (timeoutManagerShouldBeEnabled && !timeoutManagerFeatureActive) { return(StartupCheckResult.Failed( "The timeout manager is not active, but the transport has not been properly configured for this. " + "Use 'EndpointConfiguration.UseTransport<AzureStorageQueueTransport>().DelayedDelivery().DisableTimeoutManager()' to ensure delayed messages can be sent properly.")); } return(StartupCheckResult.Success); }
async Task <StartupCheckResult> TryOpenDatabaseConnection() { try { using (await connectionFactory.OpenNewConnection().ConfigureAwait(false)) { } return(StartupCheckResult.Success); } catch (Exception ex) { var message = "Could not open connection to the SQL instance. Check the original error message for details. Original error message: " + ex.Message; return(StartupCheckResult.Failed(message)); } }
public static StartupCheckResult CheckForInvalidSettings(SettingsHolder settings) { var externalTimeoutManagerAddress = settings.GetOrDefault <string>("NServiceBus.ExternalTimeoutManagerAddress") != null; if (externalTimeoutManagerAddress) { return(StartupCheckResult.Failed("An external timeout manager address cannot be configured because the timeout manager is not being used for delayed delivery.")); } var sendOnlyEndpoint = settings.GetOrDefault <bool>("Endpoint.SendOnly"); if (sendOnlyEndpoint) { return(StartupCheckResult.Failed("Native delayed delivery is only supported for endpoints capable of receiving messages.")); } return(StartupCheckResult.Success); }
public static StartupCheckResult Check() { var connectionSettings = ConfigurationManager.ConnectionStrings.Cast <ConnectionStringSettings>().ToList(); string message; var validationPassed = new ConnectionStringsValidator().TryValidate(connectionSettings, out message); if (validationPassed == false) { Logger.Error(message); return(StartupCheckResult.Failed(message)); } return(StartupCheckResult.Success); }
public static StartupCheckResult CheckForInvalidSettings(ReadOnlySettings settings) { var externalTimeoutManagerAddress = settings.GetOrDefault <string>("NServiceBus.ExternalTimeoutManagerAddress") != null; var timeoutManagerFeatureActive = settings.GetOrDefault <FeatureState>(typeof(TimeoutManager).FullName) == FeatureState.Active; var timeoutManagerDisabled = settings.GetOrDefault <bool>(WellKnownConfigurationKeys.DelayedDelivery.DisableTimeoutManager); if (externalTimeoutManagerAddress) { return(StartupCheckResult.Failed("An external timeout manager address cannot be configured because the timeout manager is not being used for delayed delivery.")); } if (!timeoutManagerDisabled && !timeoutManagerFeatureActive) { return(StartupCheckResult.Failed( "The timeout manager is not active, but the transport has not been properly configured for this. " + "Use 'EndpointConfiguration.UseTransport<AzureStorageQueueTransport>().DelayedDelivery().DisableTimeoutManager()' to ensure delayed messages can be sent properly.")); } return(StartupCheckResult.Success); }
public async Task <StartupCheckResult> CanManage() { var client = new ManagementClient(connectionStringBuilder, tokenProvider); try { await client.QueueExistsAsync("$nservicebus-verification-queue").ConfigureAwait(false); } catch (UnauthorizedException) { return(StartupCheckResult.Failed("Management rights are required to run this endpoint. Verify that the SAS policy has the Manage claim.")); } catch (Exception exception) { return(StartupCheckResult.Failed(exception.Message)); } finally { await client.CloseAsync().ConfigureAwait(false); } return(StartupCheckResult.Success); }