I want to know:
1. If it's possible to spawn a new thread and create a DataModule within
this thread.
2. Is there any benefit to doing this ? In the sense, does the
DataModule/TSession have some way of handling multiple requests
simultaneously ?
Shiv.
When I do this, I create the datamodule dynamically withing the
TThread.Execute method. Therefore, each thread will have its own
datamodule instance and its own session.
--- x
==============================
Xavier Pacheco (TeamB)
xav...@xapware.com
Sorry but TeamB cannot answer support
questions received via email.
Over the weekend I put together two examples of doing this for someone
else. If you would like a copy of those two little examples e-mail me
and I'll send it to you.
--
---------------------------------------------------------------------
Jeff Overcash (TeamB) On waves of silver I dreamed of gold
(Please do not email 'Till I lost the peace that dreaming gives
me directly unless I dreamed of the moment of my own death
asked. Thank You) That no one ever dreams and lives (Marillion)
---------------------------------------------------------------------
What would be the advantages / disadvantages of this design ? I can
understand the overhead in creating a new instance of a DataModule for each
request.
This is what I'm doing...
I'm building a 3-tiered system using sockets as the transport layer.
In the applcation server layer I currently have a DataModule with a TSession
(AutoSessionName := True) and TDatabase component. For every client
connection, I am spawning a new thread for the actual transfer of data and
requests. But all threads use the same datamodule. I don't have good feeling
about that !
So my questions again...
What are the disadvantages of this design versus the new instance of a
datamodule (created within each thread) . So far I have not had problems
with multi-users. But will I ? What about the number of sessions hitting the
database server ?
Shiv.
Xavier Pacheco (TeamB) wrote in message
<373a0c07....@forums.inprise.com>...
Dan
The same *instance*, or *class*???
> What are the disadvantages of this design versus the new instance of a
> datamodule (created within each thread) . So far I have not had problems
> with multi-users. But will I ? What about the number of sessions hitting
the
> database server ?
If you only have one DataModule that all threads can use, then you would
need to protect that DataModule with a critical section (or some other
means), which means only one thread at a time can use it. This would cause
major performance problems (obviously). You want to be able create multiple
threads so that more than one user at a time can be doing database access in
your application server. However, the danger is having too many threads
(and too many sessions/database connections). Too many threads means a lot
of context-switching, which will hurt performance. The number of database
connections is a totally different issue.
HTH,
Dan
can i get the code for those 2 examples that u offered to Shiv?
i would really appreciate that.
thanx
Adnan.
(in case u do want to send it to me, here is my e-mail: adnan...@aol.com)
Dan Butler <no.spam.pr...@yahoo.com> wrote in message
news:7h7n4a$n0...@forums.borland.com...
Adnan Zaman wrote:
>
> hi Xavier,
>
> can i get the code for those 2 examples that u offered to Shiv?
> i would really appreciate that.
>
> thanx
> Adnan.
> (in case u do want to send it to me, here is my e-mail: adnan...@aol.com)
>
--
Good deal. Please send my way and I'll put them in my library of
"how tos". :) -- x
This then begs another question....
Currently, I have tested my server application with about 25 concurrent
users (25 threads hitting one datamodule) , each doing updates, deletes,
inserts , views , with no problem so far !! How is it that nothing has
happened yet ? I'm not using critical sections either.
This is scary, as my server is running off of my PC at home, while the users
are the people at work (including me). If my server bombs out or crashes....
I'll change the server app to create a new instance of the DM. But if there
is any explanation for the above, I'd appreciate it.
Shiv.
Dan Butler wrote in message <7h7nls$mv...@forums.borland.com>...
the error says: "Required package: RXDB4 not found". what's this package and
how can i do a successful build? (btw, i am using delphi 4.03 (CS)).
thanx
Adnan.
Andrey Egorov <a_eg...@mtu-net.ru> wrote in message
news:7ha9s5$pc...@forums.borland.com...
Dan
Shiv Kumar <sku...@datasourceinc.com> wrote in message
news:7ha5op$p2...@forums.borland.com...
Dan
Adnan Zaman <Adnan...@aol.com> wrote in message
news:7hblrn$q9...@forums.borland.com...
Hope this helps,
Rea
Adnan Zaman wrote:
>
> thanx Jeff for sending me those files. but now i have another problem. i
> can't build the files in 'withtdat'.
>
> the error says: "Required package: RXDB4 not found". what's this package and
> how can i do a successful build? (btw, i am using delphi 4.03 (CS)).
>
> thanx
> Adnan.
>
> Andrey Egorov <a_eg...@mtu-net.ru> wrote in message
> news:7ha9s5$pc...@forums.borland.com...
> >
> > Hi Jeff!
> >
> > Please don't forget to send it to me too.
> >
> > Thank you
> >
> > Andrey (a_eg...@mtu-net.ru)
> >
--
"Jeff Overcash (TeamB)" wrote:
> That was me, not Xavier <g>. I'll send it to you.
>
> Adnan Zaman wrote:
> >
> > hi Xavier,
> >
> > can i get the code for those 2 examples that u offered to Shiv?
> > i would really appreciate that.
> >
> > thanx
> > Adnan.
> > (in case u do want to send it to me, here is my e-mail: adnan...@aol.com)
> >
>
Can I ask for one copy of those 2 examples as well?
Thanks in advance.
Wilson Sun
Manuel Perez wrote:
>
> Hi Jeff,
> I will appreciate if you send me your examples.
> Thanks in advance.
> Manuel Perez.
> email-1 : nova...@nl1.telmex.net.mx
> email-2 : nova...@compuserve.com
>
--
Thanks in advance for your comments and help, and sorry if it is a dummy
question. I am a starting to program with Delphi.
Thanks in advance for your help.
I was in the same case but I make this in the unit's Thread:
In Interfase section I add the following declaration:
Var
DBProcess: DataModuleX;
In the DataModuleX, I have:
1 TDataBase
3 TDataSet
3 TQuery
And I have not any problem with access to my DB Server. I can Insert, Edit, View
and more. In conclusion, I believe that this way is Thread Safe.
But I have the following problem. Each thread use one Lisence of my DB Server
(PROGRESS v8.2b).
1.- How can I do to make just One Connection (one lisence) shared with all
thread, with Thread Safe?
2.-When in Run-Time try to close one connection (DBProcess.Database1.Close or
DBProcess.Database1.Connected:=False) in any thread to free this lisence, my app
is aborted. Any suggestion?
Thanks
Rene Trevino
Shiv Kumar wrote:
> Thanks for the reply Xavier. I now have another question.
>
> What would be the advantages / disadvantages of this design ? I can
> understand the overhead in creating a new instance of a DataModule for each
> request.
>
> This is what I'm doing...
>
> I'm building a 3-tiered system using sockets as the transport layer.
>
> In the applcation server layer I currently have a DataModule with a TSession
> (AutoSessionName := True) and TDatabase component. For every client
> connection, I am spawning a new thread for the actual transfer of data and
> requests. But all threads use the same datamodule. I don't have good feeling
> about that !
>
> So my questions again...
>
> What are the disadvantages of this design versus the new instance of a
> datamodule (created within each thread) . So far I have not had problems
> with multi-users. But will I ? What about the number of sessions hitting the
> database server ?
>
> Shiv.
> Xavier Pacheco (TeamB) wrote in message
> <373a0c07....@forums.inprise.com>...
> >Shiv,
> > Yes it possible. The key is that the datamodule must have a
> >TSession component on it and all database connection must go thru that
> >session. The TSession.AutoName property must be set to true.
> >
> > When I do this, I create the datamodule dynamically withing the
> >TThread.Execute method. Therefore, each thread will have its own
> >datamodule instance and its own session.
> >
From Dan's comments in this Thread, He talks about . .
- Generate a pool of datamodules (database connection), to be assigned to a
thread, then lock it with a "critical section" ?
Now what I need is to have only 1 Database connection shared to be used by all
the threads/Session/Query.
Is it possible ? If so, What do I must do in your example ?
Thanks in advance for your help.
"Jeff Overcash (TeamB)" wrote:
> No you will need a minimum of two. On session is created by default in
> the main application. The threaded Query must have its own Session so
> that would make two connections. You can reuse this second session
> though with many queries.
>
> Manuel Perez wrote:
> >
> > Hi Jeff,
> > -Thanks for the examples.
> > -I have a question about the examples.
> > Is it possible to use only 1 database connection, and keep the thead
> > safe ?
> > If It is, I will appreciate if you use the examples to explain it to me.
> >
> > Thanks in advance for your comments and help, and sorry if it is a dummy
> > question. I am a starting to program with Delphi.
> >
I've been planning on getting a Session / Thread pooling example made up using
DataModules, but haven't had time. I'll see if I can get something together
this week (no promises becasue I do have some traveling involved this week, but
I'll try). Take a look at the Pooler example in the Midas section of the
examples for ideas on how to pool DataModules to limit Sessions. This example
does not use threads, but does give the basics of pooling.
Manuel Perez wrote:
>
> Hi Jeff,
> I am sorry, but I did not understand you comment.
> From you examples, I test the example and . . .
> - I monitored the Progress Database and we have 1 database connection for each
> thread/Session/Query.
> - From Delphi > view> Threads, we have 2>3>2 Threads.
>
> From Dan's comments in this Thread, He talks about . .
> - Generate a pool of datamodules (database connection), to be assigned to a
> thread, then lock it with a "critical section" ?
>
> Now what I need is to have only 1 Database connection shared to be used by all
> the threads/Session/Query.
> Is it possible ? If so, What do I must do in your example ?
>
> Thanks in advance for your help.
>
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
The fool escaped from paradise will look over his shoulder and cry
Sit and chew on daffodils and struggle to answer why?
As you grow up and leave the playground
Where you kissed your Prince and found your frog
Remember the jester that showed you tears, the script for tears. (Fish)
--