how to integrate SMS & EMAIL Reminders in my play2.0 framework web application.

前端 未结 1 890
闹比i
闹比i 2021-01-17 04:18

I\'m creating a web application in play2.0 framework.In this application i need to integrate SMS and EMAIL reminder to send sms and email on a particular date and time by g

相关标签:
1条回答
  • 2021-01-17 04:40

    In Play 1.x, this would have been achieve with the concept of Jobs. In Play 2.x, asynchronous execution of code is done using Akka's scheduler.

    So, from your use case, you will probably want to have a job that runs every few minutes (lets assume 30 for the example), that goes off to the database and checks to see if any emails need to be sent. From here, you can then call your web service to send SMS and Email.

    Akka.system().scheduler().scheduleOnce(
      Duration.create(30, TimeUnit.MINUTES),
      new Runnable() {
        public void run() {
          // check database for reminders that need to be sent
          // send email
          // send SMS
        }
      }
    ); 
    

    As for services for sending SMS, you could check out Twilio ( http://www.twilio.com/api/sms ). You just need to integrate using the play.libs.WS class.

    Email is a trivial part of the puzzle, and has been answered many times over already, so I won't go into detail on that.

    0 讨论(0)
提交回复
热议问题