Phase IV

Send Email (Bread-Project Dependency)

  • Notification by email is already available in Bread project, we need to import Bread, and actually send the mail.
  • Edit Lottery.ksmile
import-component bread-release-0.4(NotifierProcess)
    process-module LotteryProcess(LotteryReadMongo, LotteryStream,NotifierProcess) at com.metastay.lotteryprocess
  • $add-component bread-release-0.4,follow the guided steps(if any)
  • $smile
  • Edit WinnerEmailSenderProcessorCode.scala
    override def process(event: com.metastay.lotterystream.stream.LotteryRan): Unit = {
    val winner = event.winner
    val email = ParticipantQuery().name.is(winner).findOne.get.email
    val body = s"Congratulation $winner,You have won the Lottery $event.lotteryName!!"

    val message =  com.metastay.notifierprocess.message.SendMailMessage(toList = email, subject = "Won Lottery", body = body)
    grab[SmileAsyncService].publish(message)
}

Processor

  • Edit Lottery.ksmile
process-module LotteryProcess(LotteryReadMongo, LotteryStream) at com.metastay.lotteryprocess
  • $smile
  • Edit LotteryProcess.kprocess, in eclipse
    processor WinnerEmailSender {
subscribe event-ref LotteryStream::LotteryRan
}
  • $compile
  • Edit WinnerEmailSenderProcessorCode.scala
    override def process(event: com.metastay.lotterystream.stream.LotteryRan): Unit = {
    val winner = event.winner
    val email = ParticipantQuery().name.is(winner).findOne.get.email
    println(s"Congratulation $winner, you have won the lottery ${event.lotteryName}; mail to $email ")
}