Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Anyone using TMS Aurelius as web-based server for Android Apps?
Mon, Jun 10 2024 1:00 PMPermanent Link

Adam Brett

Orixa Systems

I have an app we have in development on a phone.

It is accessing an EDB database on an Amazon AWS EC2 Instance.

I am using a TMS Aurelius / XData server on the back-end, with Aurelius components on the App to access data.

It has worked well in testing.

Now we are moving to production-testing and we are getting an error

"Database name 'XXXXXXXXX' already exists"

Note that with Aurelius, you set up the database components BUT leave the Name blank. Aurelius then uses this database component to create it's own databases as it needs them.

I have done this exactly as shown in the TMS help, and it works fine while there is only 1 or 2 users connected.

Now I have a slightly higher load on the App I am getting the error above.

I think it occurs when 2 users call| "insert" at roughly the same time.

Does anyone here have experience with Aurelius they can help with??
Mon, Jun 10 2024 7:18 PMPermanent Link

Terry Swiers

I'm in the initial stages of doing something similar, so here is what I have at this point, with each Aurelius connection having it's own session and database object on the data module:

//Connection Module  OnCreateEvent:
procedure TElevateDBElevateDBConnection.DataModuleCreate(Sender: TObject);
begin
AureliusConnection.CloningMode := TCloningMode.Owner;

ConnectionSession.SessionType := stRemote;
ConnectionSession.RemoteHost := 'localhost';
ConnectionSession.OnLogin := ConnectionSessionLogin;
ConnectionSession.AutoSessionName := True;

ConnectionDB.SessionName := ConnectionSession.SessionName;
ConnectionDB.Database := 'MyDBName';
ConnectionDB.DatabaseName := IntToStr(NativeInt(ConnectionDB));

AureliusConnection.AdaptedConnection := ConnectionDB;
end;

//DB Object - make sure it has a unique name if not assigned
procedure TElevateDBElevateDBConnection.ConnectionDBBeforeConnect(Sender: TObject);
var
 Obj : TEDBDatabase;
begin
 Obj := TEDBDatabase(Sender);
 if (Obj.DatabaseName = '') then Obj.DatabaseName := IntToStr(NativeInt(Sender));
end;

//Session Object - make sure it has a unique name if not assigned
procedure TElevateDBElevateDBConnection.ConnectionSessionBeforeConnect(Sender: TObject);
var
 Obj : TEDBSession;
begin
 Obj := TEDBSession(Sender);
 if (Obj.SessionName = '') then Obj.SessionName := IntToStr(NativeInt(Sender));
end;

I still need to do some testing to make sure that this approach works the way that I want / expect as I can't see how it's going to handle multiple updates in transactions if I am using separate connections for each call.
Wed, Jun 12 2024 1:35 PMPermanent Link

Adam Brett

Orixa Systems

Thank you Terry this is super-useful.

I was adding the BeforeConnect at the database level, but not at the DataModuleCreate or the SessionConnect.

I will try adding these additional methods and see whether they improve the situation!

... By the way it is great to know there is someone else on this journey, I feel a bit lonely working with EDB on the web-side of things.

I have had some experience with XData now, and have various bits of my small system working. I am really happy to share a bit more about it if it is useful.
Wed, Jun 12 2024 1:54 PMPermanent Link

Adam Brett

Orixa Systems

Adam Brett

With a further look at your code Terry, I have removed 1 line:

ConnectionDB.SessionName := ConnectionSession.SessionName;
ConnectionDB.Database := 'MyDBName';
ConnectionDB.DatabaseName := IntToStr(NativeInt(ConnectionDB));

I have rewritten:

ConnectionDB.SessionName := ConnectionSession.SessionName;
ConnectionDB.Database := 'MyDBName';
//ConnectionDB.DatabaseName := IntToStr(NativeInt(ConnectionDB));

For me, setting the database name PRIOR to the connection does some bad magic to the Aurelius Connection and freezes the whole thing.

I hope that the addition of the rest of the code will be helpful.
Image