I need a little push in the right direction. Here's my problem: I have to create an ultra-reliable service that sends email messages to clients whose addresses are stored in txt file on FTP server. Single txt file may contain unlimited number of entries. Most often the file contains about 300,000 entries.
Service exposes interface with just two simple methods:
TaskHandle sendEmails(String ftpFilePath);
ProcessStatus checkProcessStatus(TaskHandle taskHandle);
Method sendEmails() returns TaskHandle by which we can ask for ProcessStatus.
For such a service to be reliable clustering is necessary. Processing single txt file might take a long time. Restarting one node in a cluster should have no impact on sending emails.
We use JBoss AS 4.2.0 which comes with a nice HASingletonController that ensure one instance of service is running at given time.
But once a fail-over happens, the second service should continue work from where the first one stopped.
How can I share state between nodes in a clust开发者_如何学Pythoner in such a way that leaves no possibility of sending some emails twice?
You could use messaging to decouple the file reading from the mail sending. Have one process read the file and send JMS messages, containing 1 to N email addresses, and have MDB receiving the messages and send the emails. Another option is to synchronize directly with the Database, let the reading process insert addresses and a status in the DB and have your service read the addresses from the database send emails and update status...
精彩评论