Where should I do this? can you give me a example?
5 Oca 2021 Sal, saat 23:11 tarihinde Jørn Wildt <j...@elfisk.dk> şunu yazdı: > It seems like you are missing a session.Close() ... and perhaps also some > transaction handling with a commit() or rollback() (but that is not a cause > for your problem). > > If you don’t close sessions and thus database connections, the database > layer will close them for you - but first after some idle timeout. If you > open more than you close, you eventually run out of connections. > > /Jørn > > tir. 5. jan. 2021 kl. 21.11 skrev Hakan karaoğlu <hknn.karao...@gmail.com > >: > >> Greetings, >> I have a question, I would be glad if you can help. >> >> Consider an application that heavily handles messages coming from >> Rabbitmq queue. Meanwhile, it queries the database and the data is saved >> and updated. >> >> My question is, it processes 500 of the 1000 incoming data, but the rest >> mostly gives the error I mentioned on the subject. "Pooled connection >> request timed out" I think the problem is from nhsession and somehow it >> fills the pool. >> >> What should I do, what would you recommend? >> >> Example configuration is below. >> >> *private static object lockObject = new object();* >> * private static ISessionFactory sessionFactory;* >> * private static FluentConfiguration configuration;* >> * private static ISessionFactory SessionFactory* >> * {* >> * get **{** lock (lockObject)** {* >> * if (sessionFactory == null)* >> * {* >> * sessionFactory = >> configuration.BuildSessionFactory();* >> * }* >> * return sessionFactory;* >> * }* >> * }* >> * }* >> >> >> >> >> >> >> >> >> >> >> >> *public static IServiceCollection AddSniffactorNhibernate(this >> IServiceCollection services, string connectionString) { >> Check.NotNull(connectionString); configuration = >> Fluently.Configure() >> .Database(OracleManagedDataClientConfiguration.Oracle10 >> .ConnectionString(connectionString) Mappings(m => >> m.FluentMappings.AddFromAssemblyOf<ISniffactorMapping>()); >> services.AddSingleton(SessionFactory); >> services.AddScoped(factory => >> configuration.BuildSessionFactory().OpenSession()); >> services.AddScoped(typeof(IRepository<>), typeof(NhRepositoryBase<>)); >> services.AddScoped(typeof(IUnitOfWork), typeof(NhUnitOfWork)); >> services; }And example a repopublic class >> KeywordDetectionViewRepository : NhRepositoryBase<KeywordDetectionView>, >> IKeywordDetectionViewRepository { private readonly ISession >> _session; public KeywordDetectionViewRepository(ISession session) : >> base(session) { _session = session; } >> public async Task<List<KeywordDetectionView>> GetKeywordsAsync(string >> source, string tag, LanguageTypes languageTypes) { var >> query = _session.CreateCriteria<KeywordDetectionView>(); int >> keywordId = int.Parse(tag.Substring(2)); if >> (tag.StartsWith("k_")) { >> query.Add(Restrictions.Eq("KeywordId", keywordId)); } >> else if (tag.StartsWith("v_")) { >> query.Add(Restrictions.Eq("VariationId", keywordId)); } >> query.Add(Restrictions.Eq("SourceCode", source)); >> query.Add(Restrictions.Or(Restrictions.Eq("LanguageCode", >> languageTypes.ToString().ToLowerInvariant()), >> Restrictions.IsNull("LanguageCode"))); var result = await >> query.SetCacheable(false).ListAsync<KeywordDetectionView>(); >> return (List<KeywordDetectionView>)result; } }* >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nhusers+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/nhusers/ff0cbb51-f210-412e-9058-4db704eea99fn%40googlegroups.com >> <https://groups.google.com/d/msgid/nhusers/ff0cbb51-f210-412e-9058-4db704eea99fn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > /Jørn > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to nhusers+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nhusers/CALh-yk%2BPGmAjz8AFWi%2B6jGhPbOZiBHv4Jy_UZ2gAXVUcn0dS%2Bg%40mail.gmail.com > <https://groups.google.com/d/msgid/nhusers/CALh-yk%2BPGmAjz8AFWi%2B6jGhPbOZiBHv4Jy_UZ2gAXVUcn0dS%2Bg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nhusers/CAAhRLA1p8pe2z0HkVY9jhq-nzT8ptGSBWRBgFddpKpYsmu4zmQ%40mail.gmail.com.