Search code examples
wcfcastle-windsorravendbwcffacility

ravendb, castle IoC ,Wcf facility - doc session liefstyle


What's the recommended lifestyle for raven doc session and store under a windsor ioc, wcf facility setup hosted in IIS?

I keep seeing this error:

Error TempPathInUse (JET_errTempPathInUse, Temp path already used by another database instance)`

here is my setup:

public class RavenInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For<IDocumentStore>().ImplementedBy<DocumentStore>()
                    .DependsOn(new { connectionStringName = "RavenConnectionString" })
                    .OnCreate(DoInitialisation)
                    .LifeStyle.Singleton,
                Component.For<IDocumentSession>()
                    .UsingFactoryMethod(GetDocumentSesssion)
                    .LifeStyle.Transient
                );

            container.Register(Component.For<IEventSeriesRepository>().ImplementedBy<EventSeriesRepository>().LifeStyle.Transient);
            container.Register(Component.For<IEventInstanceRepository>().ImplementedBy<EventInstanceRepository>().LifeStyle.Transient);
            container.Register(
                Component.For<IProductionCompanyRepository>().ImplementedBy<ProductionCompanyRepository>().LifeStyle.
                    Transient);
        }

        static IDocumentSession GetDocumentSesssion(IKernel kernel)
        {
            var store = kernel.Resolve<IDocumentStore>();
            return store.OpenSession();
        }

        public static void DoInitialisation(IKernel kernel, IDocumentStore store)
        {
            store.Initialize();
            IndexCreation.CreateIndexes(typeof(EventSeries_ByName).Assembly, store);

        }
    }

Solution

  • This same question about lifecycle was raised in the Raven forums: https://groups.google.com/forum/#!topic/ravendb/wUgULf3eoCg

    Ayende's response was: Singleton for the Document Store, Transient / Web Request for the session.