Getting access to the Connection Pool components

I am trying to move an existing REST server to XData framework. I have it working but want to take advantage of the connection pool. I have my ElevateDB DataModule attached to the AdaptedConnection in the AureliusConnection. How do I create/access a unique instance of that DataModule in my service's implementation? Can I access the components directly to assign them to a new table or query that I create in my service? This is my plan for now as I try to use existing code, but longer term is there a better way?

First, when using ElevateDB, it's recommended to use

AureliusConnection1.CloningMode := TCloningMode.Owner;

Because they it will also replicate the session component together with each connection. This overcomes the issue with having duplicated database and session names.

Once you have your TAureliusConnection property associated with the ElevateDB connection and creating the property IDBConnection, just drop a TXDataConnectionPool and associated it to the TAureliusConnection.

Then, to get new connections from the pool, use

Connection := XDataConnectionPool1.GetPoolInterface.GetConnection;

If you want to know the underlying TEDBDatabase component from the Connection, use the approach described here (Referencing original component):
https://download.tmssoftware.com/business/aurelius/doc/web/component_adapters.html

var
  MyConnection: IDBConnection;
  EDBDatabase: TEDBDatabase;
{...}
  EDBDatabase := (MyConnection as IDBConnectionAdapter).AdaptedConnection as TEDBDatabase;

Where do I put the line "Connection := XDataConnectionPool . . ."
and
what unit do I use to see IDBConnection

ps. I'm new to TMS and have to say your support response is amazing!

You will put that line whenever you need to get a connection from the pool.
The IDBConnection interface is declared in unit Aurelius.Drivers.Interfaces.
Thank you for the compliments, we try to do our best! ;-)

Should this code work:

procedure TdmRest.DataModuleCreate(Sender: TObject);
begin
Connection := TXDataOperationContext.Current.GetConnectionPool.GetConnection;
EDBDatabase := (Connection as idbconnectionadapter).AdaptedConnection as TEDBDatabase;

qryTemp_.DatabaseName := EDBDatabase.Name;
qryTemp_.SessionName := EDBDatabase.Session.Name;
tblEventLog_.DatabaseName := EDBDatabase.Name ;
tblEventLog_.SessionName := EDBDatabase.Session.Name;

bDebug := False;
end;

It doesn't create an error but the session names are not adhering to the autosessionname property and therefore don't work

Sorry for the confusion. My mistake (brain cramp). This works

procedure TdmRest.DataModuleCreate(Sender: TObject);
begin
Connection := TXDataOperationContext.Current.GetConnectionPool.GetConnection;
EDBDatabase := (Connection as idbconnectionadapter).AdaptedConnection as TEDBDatabase;
EDBDatabase.Connected := True;

qryTemp_.DatabaseName := EDBDatabase.DatabaseName;
qryTemp_.SessionName := EDBDatabase.SessionName;
tblEventLog_.DatabaseName := EDBDatabase.DatabaseName ;
tblEventLog_.SessionName := EDBDatabase.SessionName;

bDebug := False;
end;

1 Like