I am building a mail queueing system using LLBL Gen and am trying to figure out how to get around some concurrency issues.
I have a table structure similar to the following:
tblBatch
BatchID
BatchOpened
BatchCount
BatchComplete
tblBatchMail
BatchMailID
BatchID
MailID
tblMail
MailID
CompanyID
UserID
MailDate
LetterID
tblLetter
FromAddress
FromName
ToAddress
ToName
Subject
Body
ContentType
Mail is queued by creating a tblMail Entity and a corresponding tblLetter. All of this works great.
The problem that I am having is when I pull batches to our web clients. The process is the following
1) Create tblBatch Entity
2) build a tblMail collection based on certain criteria of both tblMail and tblLetter
3) create tblBatchMail Entities for each tblMail entity in the collection
4) pull down the tblMail Collection to the web client for processing.
Everything works fine with this as long as I just have a single web client processing at one time… I was hoping to get thoughts on the best way to accomplish this when I have to scale out to multiple web clients all requesting batches simultaneously…without assigning mail to mutiple batches.
I had considered a simple
Synclock(me)
BuildBatch
End Sync
But didn’t know if there was a better way – i.e. move the batchId assignements directly to tblMail and then do an updatemulti() on the tblMail Collection…
Any thoughts or suggestions would be greatly appreciated.
Best Regards,
Hal