# How to implement a self invoked scheduler?
First define the message that needs to be sent to self.
Include the message in the processor's definition as a
self message-ref.message TimeToSchedule processor RequestScheduler{ self message-ref TimeToSchedule }Use the api
sendToSelfinside 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)
}