Wikia

Delphi Programming

TnxSessionPool

2,918pages on
this wiki
Talk0

OverviewEdit

Creates a pool of client-side database sessions to improve performance and scaleability of applications connecting to NexusDB databases, in particular multi-threaded applications.

UsageEdit

Adapted from newgroup postings to nexusdb.public.support by Thorsten Engler of NexusDB support.

Multi-threaded codeEdit

If you need a session for a limited time you can:

  1. setup a TnxSessionPool
  2. inside your threads
    1. Create your databases / tables / queries.
    2. Call TnxSessionPool.AcquireSession
    3. Assign the returned session to your TnxDatabase
    4. Use your table and query components as normal.
    5. When done free everything except the session
  3. call TnxSession.Release to put it back into the pool.

Remote PluginsEdit

TnxSessionPool, just like TnxSession, implements InxSessionRequests. That interface is required for "remote plugins". Normally you would connect a remote plugin of some kind to a session, and then only call that plugin from the thread that owns the session.

If you connect a remote plugin to a session pool it will automatically use a session from the pool for each request, meaning you can now call your plugin from any number of threads at the same time. (Assuming the plugin itself is written in a way that it can handle multi-threaded usage.)

Around Wikia's network

Random Wiki