Akka 2: How to pause processing of messages?

前端 未结 2 2115
不知归路
不知归路 2021-02-14 09:04

On my journey to grasp the Actor model using Akka many questions pop up. Here is another one. Say we have an Actor which has to stop processing messages for a given time because

2条回答
  •  萌比男神i
    2021-02-14 09:41

    case object NextEmail
    class EmailActor extends Actor {
    
    self ! NextEmail
    
      def receive = {
        case NextEmail =>
          sendEmailIfAnyToSend
          context.system.scheduler.scheduleOnce(3 seconds, self, NextEmail)                 
      }
    }
    

提交回复
热议问题