Hi Daniel, 16 mar 2014 kl. 04:11 skrev Daniel Wang <[email protected]>:
> 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 could potentially implement this as a special type of mailbox, but I would recommend against that: the Mailbox is just a mechanism for getting messages to an actor, and the Actor shall define how to process those messages. Skipping some of them falls within the responsibility of the Actor. Regards, Roland > > -- > >>>>>>>>>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. Dr. Roland Kuhn Akka Tech Lead Typesafe – Reactive apps on the JVM. twitter: @rolandkuhn -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
