Reputation: 2347
I would like to drop earlier messages from an actor. The base idea is to have a timestamp on each message, store it for the last processed message message and drop messages earlier than this timestamp.
I am thinking to create mailbox for that, however I don't know:
Maybe I am trying to something wrong and there is a better alternative for that ?
Thanks
Upvotes: 2
Views: 85
Reputation: 3181
Writing a custom mailbox for that is overkill. You can solve it like this:
class MyActor extends Actor {
val timestampLimit: LocalDateTime = ???
def receive = {
case m: Message if (m.getTimeStamp.isBefore(timestampLimit)) => // drop
case m: Message => // process
}
}
Upvotes: 1