#1 2022-08-10 15:21:55

MARCOSMENDES
Member
Registered: 2022-08-10
Posts: 5

How access WebServer simultaneously with two threads

hello folks!

I am a developer of a company in Brazil. We are make migration of owner ERP this company. The technology currently used  is DATASNAP and we are make adaptation for mORMot without uses of ORM. There for, we used the exemple of folder ..\16 - Execute SQL via services. Until right now, all the implementations of data access went maked successes full, but when we need used thread for make two simultaneous connection for access on server, the result is not expected! Is like if the second thread waited the first thread to be finished for maked your process! We are use FireDAC for data access e maked a small example ("162 - Execute SQL via services - Thread") based in your example 16.

New Link:  https://drive.google.com/file/d/13rokeK … sp=sharing

PS:
I would like to say that my example is very simple. It only keep two connections with Web Server and use each one for make request simultaneous throw of threads. To test, i maked first query with more time response and the second more simple with response immediate! But unfortunately, the second request waited the first resquest finish.

thanks per attention!

Last edited by MARCOSMENDES (2022-08-11 12:35:13)

Offline

#2 2022-08-11 06:13:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: How access WebServer simultaneously with two threads

I have not access to you drive link, but anyway I guess that your concern is that a mORMot client is thread-safe, but blocking.

You have to use one TRestClient per thread, if you want concurrent calls.

If you have very long process, see the sample about how interface callbacks could help for a "long work" kind of request.

Offline

#3 2022-08-11 06:16:48

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: How access WebServer simultaneously with two threads

If it's based on 16 sample, then it's configured to execute in main thread, try to comment line with SetOptions.

Check documentation for sicClientDriven (if not needed to store some client specific data, use sicShared) and optExecInMainThread

Offline

#4 2022-08-11 12:38:41

MARCOSMENDES
Member
Registered: 2022-08-10
Posts: 5

Re: How access WebServer simultaneously with two threads

Offline

#5 2022-08-11 13:43:11

MARCOSMENDES
Member
Registered: 2022-08-10
Posts: 5

Re: How access WebServer simultaneously with two threads

Thanks a lot igors233! At first, to comment SetOptions solved it, but yet we to be make some tests.

Offline

#6 2022-08-11 19:50:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: How access WebServer simultaneously with two threads

See https://synopse.info/files/html/Synopse … ml#TITL_72

Those settings and behavior apply to mORMot 2 too.

Offline

Board footer

Powered by FluxBB