# How to implement a self invoked scheduler?

  1. First define the message that needs to be sent to self.

  2. Include the message in the processor's definition as a self message-ref.

    message TimeToSchedule
    processor RequestScheduler{
    	self message-ref TimeToSchedule
    }
    
  3. Use the api sendToSelf inside the processor-code to send a message to self.

    For example: the following code sends message to itself after 5 seconds.

    sendToSelf(message = TimeToSchedule, inSeconds = 5, sender = ActorRef.noSender)
    

Note: Ideally such messages will be first invoked in the preStart of the processor as follows:

override def preStart(): Unit = {
    sendToSelf(message = TimeToSchedule, inSeconds = 3, sender = ActorRef.noSender)
}