Reputation: 4185
I would like to setup a small program that retrieves info from a database and then distributes that information to another program when requested. For instance, a program called 'Master' would retrieve data from the database and create a collection of objects (list, array, etc. whatever works best) and then a program called 'Slave' (running from multiple desktops) could call a method (i.e., GetNextRecord) from 'Master' to retrieve the next record in the collection.
I would like to be able to only allow one 'Slave' to be able to call the GetNextRecord method at a time to avoid giving multiple slaves the same record. 'Master' would run on the server with the database while 'Slave' would be running on multiple desktop machines.
Does anyone have an example of this or a tutorial on how this is done?
TIA, Brian Enderle
Upvotes: 7
Views: 1997
Reputation: 36664
What you are describing is also known as load balancing, which can be implemented using a Message Queue.
Look up Message Oriented Middleware and check existing implementations, like Microsoft Message Queuing (MSMQ):
MSMQ is essentially a messaging protocol that allows applications running on separate servers/processes to communicate in a failsafe manner.
A recommended read is also the book about Enterprise Integration Patterns
Note: I am the author of Delphi and Free Pascal client libraries for open source message queues / message brokers (ActiveMQ, HornetQ, OpenMQ, RabbitMQ)
Upvotes: 1
Reputation: 1298
I would look at DataSnap in Delphi XE. There is a free DataSnap 2010 white paper with videos at http://www.embarcadero-info.com/in_action/radstudio/db.html and I'm currently working on a Delphi XE small but real-world case study application for another white paper (probably published next month or early 2011). In the meantime, you can also check out my Delphi XE DataSnap Development Essentials courseware manual published today at http://www.eBob42.com/courseware (see TOC at http://www.ebob42.com/training/DataSnapXE.pdf).
If you don't have the Enterprise edition of Delphi, and don't want to upgrade to it, then you may want to give RemObjects SDK a look.
Note: I'm reseller of both, but I also use both in actual projects for and with customers, so I do know what I'm talking about ;-)
Upvotes: 0
Reputation: 14883
What you are describing is generally known as three-tier or multi-tier design.
There are some Delphi libraries out there to make it easier:
Related question:
Advice on moving to a multi tier Delphi architecture
Upvotes: 12