Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

My program allows users to store appointments in a calendar. What has been requested of me is the ability for SMS reminders to be sent to people to remind them of their appointment. The SMS would need to be sent out about 2 days prior to their appointment.

I thought the best way to achieve this is to choose a time of the day (eg. midday) for the software to check to see which appointments are in 2 days time and then send out the SMS reminders to the people who have those appointments.

Would this be an advisable approach to this problem? Is it advisable to have this happen at one time of the day, or would it be better to somehow spread it out over a longer time?

I am assuming at this point that a background thread would be a good idea for this type of activity.

share|improve this question
2  
Which platform? Usually, OSes have built-in components for running tasks at given times. –  mouviciel Jul 25 '12 at 7:45
    
I would want this to be part of the program. –  CJ7 Jul 25 '12 at 7:55
    
appointment % some_value will give you the appointment remainder. –  Thomas Eding Aug 24 '12 at 23:06
add comment

3 Answers

This Question should be proposed to the user, as the ramifications to the user far out way the technical concerns.

The frequency that you call your process should have very little baring on the design.

share|improve this answer
add comment

If its two days prior to the appointment it would in my opinion be sufficient to check once a day. I think outlook does it at startup when you say: remind me 2 days before the event. For me it wouldn't make much sense to check that hourly, because it probably wont matter if I read the SMS at 8 AM or 6 PM.

Maybe the best way to be sure is to have a use case or requirement of the end user, and ask him when he expects the notification.

Unfortunately I don't know which language you program in. If it's Java or C#, you may want to take a look at Quartz (Java, C#). You can easily specify how often and when exactly a task should be executed. Maybe you can use it.

share|improve this answer
    
This is almost exactly what I was going to say. –  Jamie Taylor Jul 25 '12 at 7:47
    
If my software is being used by more than one person in an office, how do I make sure the task is only performed once per day and not by all instances of the software? –  CJ7 Jul 25 '12 at 7:59
    
@CraigJ Do you have a server which hosts the database, or does the program just store the appointments locally on their computer? Because preferably you would implement the check on server side, where you are not dependent that the client applications are running. This way the users will get the SMS even they did not start your program that day (maybe they are in meetings the whole day). –  Slomo Jul 25 '12 at 8:07
    
There is a central database which all instances of the program run against. There is no application process on the server. –  CJ7 Jul 25 '12 at 8:18
1  
@CraigJ As I said, I think it's better to have this as a task on the server. People already mentioned that Operating Systems can invoke tasks (programs) en.wikipedia.org/wiki/Cron. You could start a short program on the server which checks and sends the sms. If you really don't want something on the server, you will face some problems: If no application is running, no reminder gets sent. If you check on startup, you have to store the date when it was last checked, because you don't want to execute it multiple times a day. –  Slomo Jul 25 '12 at 8:30
show 1 more comment

This is a queue problem. When you set the reminder your create a "task". That task has some status, like open and a minimum date time before it may start. So, you check the task list. You can just do that multiple times per day, could even be a continuous process.

When you start working on a task you set it to pending and when done remove it or close it. Depending on the amount of history you want. That way you can always just restart the service, run it on many machines etc. As long as your locking is ok on changing the task status you will be ok.

In general it is advisable if you do this with real queue software. Creating one yourself which is scalable is quite hard actually because of locking issues, servers which get down etc.

share|improve this answer
    
It would have to part of the software itself. No external services or other programs. If all instances of the software begin to start processing the queue at once, what will be the likely result? –  CJ7 Jul 25 '12 at 8:25
1  
What I stated in the answer a queue software piece handles the process of making sure a task is only executed once. So you could build your own solution for that but it becomes the same in the end, you are building a queue. So, if you build it in your own application you have to take care strictly about logging, catching failed servers during a process, handling unavailability of the SMS service etc. Normally a queue process (so sending the sms) should work like: Try to send it, if it fails return it failed. Then the queue can pick it up again. The queue will wait for a specified time for it. –  Luc Franken Jul 25 '12 at 8:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.