public void Specific_stores_should_mask_default()
        {
            using (var db = new ReusableDB())
            {
                var settings = new SettingsHolder();
                settings.Set("Transactions.SuppressDistributedTransactions", true);
                settings.Set("TypesToScan", new Type[0]);
                settings.Set("NServiceBus.Routing.EndpointName", "FakeEndpoint");
                settings.Set("NServiceBus.Transport.TransportInfrastructure", new FakeRavenDBTransportInfrastructure(TransportTransactionMode.None));
                settings.Set("Endpoint.SendOnly", true);

                DocumentStoreManager.SetDocumentStore <StorageType.GatewayDeduplication>(settings, db.NewStore("GatewayDeduplication"));
                DocumentStoreManager.SetDocumentStore <StorageType.Outbox>(settings, db.NewStore("Outbox"));
                DocumentStoreManager.SetDocumentStore <StorageType.Sagas>(settings, db.NewStore("Sagas"));
                DocumentStoreManager.SetDocumentStore <StorageType.Subscriptions>(settings, db.NewStore("Subscriptions"));
                DocumentStoreManager.SetDocumentStore <StorageType.Timeouts>(settings, db.NewStore("Timeouts"));
                DocumentStoreManager.SetDefaultStore(settings, db.NewStore("Default"));

                var readOnly = settings as ReadOnlySettings;

                Assert.AreEqual("GatewayDeduplication", DocumentStoreManager.GetDocumentStore <StorageType.GatewayDeduplication>(readOnly).Identifier);
                Assert.AreEqual("Outbox", DocumentStoreManager.GetDocumentStore <StorageType.Outbox>(readOnly).Identifier);
                Assert.AreEqual("Sagas", DocumentStoreManager.GetDocumentStore <StorageType.Sagas>(readOnly).Identifier);
                Assert.AreEqual("Subscriptions", DocumentStoreManager.GetDocumentStore <StorageType.Subscriptions>(readOnly).Identifier);
                Assert.AreEqual("Timeouts", DocumentStoreManager.GetDocumentStore <StorageType.Timeouts>(readOnly).Identifier);
            }
        }
        public void Should_create_default_connection()
        {
            var settings = DefaultSettings();

            var storeInitializer = DocumentStoreManager.GetUninitializedDocumentStore <StorageType.Timeouts>(settings);

            storeInitializer.EnsureDocStoreCreated(settings);
            Assert.AreEqual("http://localhost:8080", storeInitializer.Url);
            Assert.AreEqual("http://localhost:8080 (DB: FakeEndpoint)", storeInitializer.Identifier);
        }
        protected override void Setup(FeatureConfigurationContext context)
        {
            var store = DocumentStoreManager.GetDocumentStore <StorageType.Timeouts>(context.Settings);

            context.Container.ConfigureComponent(() => new TimeoutPersister(store), DependencyLifecycle.InstancePerCall);
            context.Container.ConfigureComponent(() => new QueryTimeouts(store, context.Settings.EndpointName()), DependencyLifecycle.SingleInstance);  // Needs to be SingleInstance because it contains cleanup state

            context.Container.ConfigureComponent <QueryCanceller>(DependencyLifecycle.InstancePerCall);
            context.RegisterStartupTask(b => b.Build <QueryCanceller>());
        }
Esempio n. 4
0
        public void Should_set_specific_document_store()
        {
            var settings = new SettingsHolder();

            DocumentStoreManager.SetDocumentStore <StorageType.Sagas>(settings, FakeStore("Sagas"));
            DocumentStoreManager.SetDocumentStore <StorageType.Timeouts>(settings, FakeStore("Timeouts"));
            DocumentStoreManager.SetDefaultStore(settings, FakeStore("Default"));
            var readOnly = settings as ReadOnlySettings;

            Assert.AreEqual(_fakeStores["Sagas"], DocumentStoreManager.GetDocumentStore <StorageType.Sagas>(readOnly));
            Assert.AreEqual(_fakeStores["Timeouts"], DocumentStoreManager.GetDocumentStore <StorageType.Timeouts>(readOnly));
        }
Esempio n. 5
0
        public void RegisterServices(Container container)
        {
            container.RegisterSingleton <IDocumentStore>(() =>
            {
                var url    = ConfigurationManager.AppSettings["RavenDbUrl"];
                var apiKey = ConfigurationManager.AppSettings["RavenDbApiKey"];
                return(DocumentStoreManager.GetCurrent(url, apiKey));
            });

            container.RegisterPerWebRequest <IMessageCounter, RavenDbMessageCounter>();
            container.RegisterPerWebRequest <IMessageRepository, RevenDbMessageRepository>();
        }
Esempio n. 6
0
        protected override void Setup(FeatureConfigurationContext context)
        {
            var store = DocumentStoreManager.GetDocumentStore <StorageType.Outbox>(context.Settings);

            context.Container.ConfigureComponent(b => new OutboxPersister(store, context.Settings.EndpointName()), DependencyLifecycle.InstancePerCall);

            context.Container.ConfigureComponent(b => new OutboxRecordsCleaner(store), DependencyLifecycle.InstancePerCall);

            context.Container.ConfigureComponent <OutboxCleaner>(DependencyLifecycle.InstancePerCall);

            context.RegisterStartupTask(builder => builder.Build <OutboxCleaner>());
        }
Esempio n. 7
0
        protected override void Setup(FeatureConfigurationContext context)
        {
            context.Container.ConfigureComponent <MartenSynchronizedStorageAdapter>(DependencyLifecycle.SingleInstance);
            context.Container.ConfigureComponent <MartenSynchronizedStorage>(DependencyLifecycle.SingleInstance);

            IDocumentStore store = DocumentStoreManager.GetDocumentStore <StorageType.Sagas>(context.Settings);

            //Todo: Add Provided Session Behavior?

            //Todo: make sure this behavior is executed AFTER correct step in pipeline...
            context.Pipeline.Register("OpenMartenSession", new OpenSessionBehavior(store), "Makes sure that there is a Marten IDocumentSession available on the pipeline");
        }
Esempio n. 8
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.Register(c =>
            {
                var url    = ConfigurationManager.AppSettings["RavenDbUrl"];
                var apiKey = ConfigurationManager.AppSettings["RavenDbApiKey"];
                return(DocumentStoreManager.GetCurrent(url, apiKey));
            }).As <IDocumentStore>().SingleInstance();

            builder.RegisterType <RavenDbMessageCounter>().AsImplementedInterfaces().InstancePerHttpRequest();
            builder.RegisterType <RevenDbMessageRepository>().AsImplementedInterfaces().InstancePerHttpRequest();

            base.Load(builder);
        }
        public void Should_construct_store_based_on_connection_params()
        {
            var connectionParams = new ConnectionParameters
            {
                Url          = TestConstants.RavenUrl,
                DatabaseName = "TestConnectionParams",
                ApiKey       = TestConstants.RavenApiKey
            };

            var settings = DefaultSettings();

            settings.Set(RavenDbSettingsExtensions.DefaultConnectionParameters, connectionParams);

            var storeInitializer = DocumentStoreManager.GetUninitializedDocumentStore <StorageType.Sagas>(settings);

            storeInitializer.EnsureDocStoreCreated(settings);
            Assert.AreEqual(TestConstants.RavenUrl, storeInitializer.Url);
            Assert.AreEqual($"{TestConstants.RavenUrl} (DB: TestConnectionParams)", storeInitializer.Identifier);
        }
Esempio n. 10
0
        public void Specific_stores_should_mask_default()
        {
            using (var db = new ReusableDB())
            {
                var cfg = new EndpointConfiguration("FakeEndpoint");
                cfg.UseTransport(new LearningTransport());
                cfg.SendOnly();

                var persistence = cfg.UsePersistence <RavenDBPersistence>();
                var settings    = persistence.GetSettings();

                DocumentStoreManager.SetDocumentStore <StorageType.Outbox>(settings, db.NewStore("Outbox"));
                DocumentStoreManager.SetDocumentStore <StorageType.Sagas>(settings, db.NewStore("Sagas"));
                DocumentStoreManager.SetDocumentStore <StorageType.Subscriptions>(settings, db.NewStore("Subscriptions"));
                DocumentStoreManager.SetDefaultStore(settings, db.NewStore("Default"));

                var readOnly = settings as ReadOnlySettings;

                Assert.AreEqual("Outbox", DocumentStoreManager.GetDocumentStore <StorageType.Outbox>(readOnly, null).Identifier);
                Assert.AreEqual("Sagas", DocumentStoreManager.GetDocumentStore <StorageType.Sagas>(readOnly, null).Identifier);
                Assert.AreEqual("Subscriptions", DocumentStoreManager.GetDocumentStore <StorageType.Subscriptions>(readOnly, null).Identifier);
            }
        }
 /// <summary>
 ///     Configures the storages to use the given document store supplied
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="storeCreator">A Func that will create the document store on NServiceBus initialization.</param>
 /// <returns></returns>
 public static PersistenceExtensions <RavenDBPersistence> SetDefaultDocumentStore(this PersistenceExtensions <RavenDBPersistence> cfg, Func <ReadOnlySettings, IDocumentStore> storeCreator)
 {
     DocumentStoreManager.SetDefaultStore(cfg.GetSettings(), storeCreator);
     return(cfg);
 }
 /// <summary>
 ///     Configures the storages to use the given document store supplied
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="documentStore">Document store managed by me as a user</param>
 /// <returns></returns>
 public static PersistenceExtensions <RavenDBPersistence> SetDefaultDocumentStore(this PersistenceExtensions <RavenDBPersistence> cfg, IDocumentStore documentStore)
 {
     DocumentStoreManager.SetDefaultStore(cfg.GetSettings(), documentStore);
     return(cfg);
 }
Esempio n. 13
0
 /// <summary>
 ///     Configures the given document store to be used when storing subscriptions
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="storeCreator">A Func that will create the document store on NServiceBus initialization.</param>
 public static PersistenceExtensions <RavenDBPersistence> UseDocumentStoreForSubscriptions(this PersistenceExtensions <RavenDBPersistence> cfg, Func <ReadOnlySettings, IDocumentStore> storeCreator)
 {
     DocumentStoreManager.SetDocumentStore <StorageType.Subscriptions>(cfg.GetSettings(), storeCreator);
     return(cfg);
 }
Esempio n. 14
0
 /// <summary>
 ///     Configures the given document store to be used when storing subscriptions
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="documentStore">The document store to use</param>
 public static PersistenceExtensions <RavenDBPersistence> UseDocumentStoreForSubscriptions(this PersistenceExtensions <RavenDBPersistence> cfg, IDocumentStore documentStore)
 {
     DocumentStoreManager.SetDocumentStore <StorageType.Subscriptions>(cfg.GetSettings(), documentStore);
     return(cfg);
 }
Esempio n. 15
0
 /// <summary>
 ///     Configures the given document store to be used when storing gateway deduplication data
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="documentStore">The document store to use</param>
 public static PersistenceExtensions <RavenDBPersistence> UseDocumentStoreForGatewayDeduplication(this PersistenceExtensions <RavenDBPersistence> cfg, IDocumentStore documentStore)
 {
     DocumentStoreManager.SetDocumentStore <StorageType.GatewayDeduplication>(cfg.GetSettings(), documentStore);
     return(cfg);
 }
Esempio n. 16
0
 /// <summary>
 ///     Configures the given document store to be used when storing sagas
 /// </summary>
 /// <param name="cfg">Object to attach to</param>
 /// <param name="documentStore">The document store to be used</param>
 public static PersistenceExtensions <MartenPersistence> UseDocumentStoreForSagas(this PersistenceExtensions <MartenPersistence> cfg, IDocumentStore documentStore)
 {
     DocumentStoreManager.SetDocumentStore <StorageType.Sagas>(cfg.GetSettings(), documentStore);
     return(cfg);
 }
 /// <summary>
 ///     Configures the given document store to be used when storing timeouts
 /// </summary>
 /// <param name="cfg"></param>
 /// <param name="storeCreator">A Func that will create the document store on NServiceBus initialization.</param>
 public static PersistenceExtensions <MartenPersistence> UseDocumentStoreForTimeouts(this PersistenceExtensions <MartenPersistence> cfg, Func <ReadOnlySettings, IDocumentStore> storeCreator)
 {
     DocumentStoreManager.SetDocumentStore <StorageType.Timeouts>(cfg.GetSettings(), storeCreator);
     return(cfg);
 }