void ApplyConventions(ReadOnlySettings settings) { if (DocumentIdConventionsExtensions.NeedToApplyDocumentIdConventionsToDocumentStore(settings)) { var sagasEnabled = settings.IsFeatureActive(typeof(Sagas)); var timeoutsEnabled = settings.IsFeatureActive(typeof(TimeoutManager)); var idConventions = new DocumentIdConventions(docStore, settings.GetAvailableTypes(), settings.EndpointName(), sagasEnabled, timeoutsEnabled); docStore.Conventions.FindTypeTagName = idConventions.FindTypeTagName; } var store = docStore as DocumentStore; if (store == null) { return; } var isSendOnly = settings.GetOrDefault <bool>("Endpoint.SendOnly"); if (!isSendOnly) { var usingDtc = settings.GetRequiredTransactionModeForReceives() == TransportTransactionMode.TransactionScope; if (usingDtc) { throw new Exception("RavenDB Persistence does not support Distributed Transaction Coordinator (DTC) transactions. You must change the TransportTransactionMode in order to continue. See the RavenDB Persistence documentation for more details."); } } #if NET452 store.EnlistInDistributedTransactions = false; #endif }
void ApplyConventions(ReadOnlySettings settings) { if (DocumentIdConventionsExtensions.NeedToApplyDocumentIdConventionsToDocumentStore(settings)) { var sagasEnabled = settings.IsFeatureActive(typeof(Sagas)); var timeoutsEnabled = settings.IsFeatureActive(typeof(TimeoutManager)); var idConventions = new DocumentIdConventions(docStore, settings.GetAvailableTypes(), settings.EndpointName(), sagasEnabled, timeoutsEnabled); docStore.Conventions.FindTypeTagName = idConventions.FindTypeTagName; } var store = docStore as DocumentStore; if (store == null) { return; } bool suppressDistributedTransactions; if (settings.TryGet("Transactions.SuppressDistributedTransactions", out suppressDistributedTransactions) && suppressDistributedTransactions) { store.EnlistInDistributedTransactions = false; } else { if (store.JsonRequestFactory == null) // If the DocStore has not been initialized yet { if (store.ResourceManagerId == Guid.Empty || store.ResourceManagerId == ravenDefaultResourceManagerId) { var resourceManagerId = settings.LocalAddress(); store.ResourceManagerId = DeterministicGuidBuilder(resourceManagerId); } // If using the default (Volatile - null should be impossible) then switch to IsolatedStorage // Leave alone if LocalDirectoryTransactionRecoveryStorage! if (store.TransactionRecoveryStorage == null || store.TransactionRecoveryStorage is VolatileOnlyTransactionRecoveryStorage) { store.TransactionRecoveryStorage = new IsolatedStorageTransactionRecoveryStorage(); } } var dtcSettingsNotIdeal = store.ResourceManagerId == Guid.Empty || store.ResourceManagerId == ravenDefaultResourceManagerId || !(store.TransactionRecoveryStorage is LocalDirectoryTransactionRecoveryStorage); if (dtcSettingsNotIdeal) { Logger.Warn("NServiceBus has detected that a RavenDB DocumentStore is being used with Distributed Transaction Coordinator transactions, but without the recommended production-safe settings for ResourceManagerId or TransactionStorageRecovery. Refer to \"Setting RavenDB DTC settings manually\" in the NServiceBus documentation for more information."); } } }