In Akka, you can approximate this behavior with timeouts + some heuristic (wait for n messages or y ms timeout). Maybe a custom mailbox could help. Your enqueue implementation could just replace the latest message if you are sure that is exactly how you plan to use. All concurrency caveats apply of course.
I haven't used Akka's bounded mailbox implementations but at first glance it seems like they are backed by blocking queues, which means instead of replacing the contents of the only slot, the producer will block till there is an empty slot.
I want one of my actors to deal with some 'MarketUpdate" messages. Since I only care about the latest/last message received, I'd like my actor to discard all pending messages in its mailbox except the last one. Shall I just use a bounded mailbox and set its mailbox-capacity to 1. Will that work?
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
Hi Daniel,16 mar 2014 kl. 04:11 skrev Daniel Wang <dan...@coinport.com>:I want one of my actors to deal with some 'MarketUpdate" messages. Since I only care about the latest/last message received, I'd like my actor to discard all pending messages in its mailbox except the last one. Shall I just use a bounded mailbox and set its mailbox-capacity to 1. Will that work?No, that will give you the “first” one; I put that in quotes because in a concurrent system it is not well-defined which message that actually is.If your intention is to skip processing “old” messages, then I would suggest sending an actor-internal Marker message to `self`when processing of one message is done, receive all messages up to that Marker (keeping track only of the previous real message) and then process the “last” one.
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/p8ZxE2UV8pA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.