On Mon, Feb 9, 2015 at 1:30 PM, Anders Båtstrand <ander...@gmail.com> wrote:

> Done: https://github.com/akka/akka/issues/16797
>
> The reason I am missing the "defer" that executes before the next message
> is processed, is because I am re-using the callbacks.
>
> Callbacks in Java are so verbose that I create re-usable components of
> simple tasks like apply-this-message-to-the-state-object.
>

public void <A> runCallback(A event, Procedure<A> handler) {
  handler.apply(event);
}

:) ?


>
> My problem was this:
>
> I have a parent actor, which forwards the message to a child actor based
> on some ID. In case the ID is unknown, it persists a "create-child"-event.
> After that callback executed, the actor is created. In a "defer"-callback,
> I then forwards the message to the child actor.
>
> If the ID is known, the parent forwards directly.
>
> The problem was message ordering. Since the "defer" was sometimes executed
> AFTER the next message was forwarded, the messages arrived out-of-order.
>
> In my case I solved it by creating yet another re-usable callback, that
> created a new actor AND forwarded the message to it.
>
> Best regards,
>
> Anders
>
> onsdag 4. februar 2015 14.23.23 UTC+1 skrev Anders Båtstrand følgende:
>
>> Dear users
>>
>> I find the semantics of "defer" confusing.
>>
>> I thought defer was the same as persist, except the given message was not
>> persisted. Now today, when a bug got me to read the doc again, it states
>> that defer has the same semantics as persistAsync.
>>
>> My first thought was that "defer" should be renamed "deferAsync", to
>> communicate the relation to persistAsync. Both are async, but the point is
>> that persist is executed before the next command is processed, while
>> persistAsync is not.
>>
>> Names aside, is there a function similar to defer, that is guaranteed to
>> be executed before the next command is processed?
>>
>> Best regrads,
>>
>> Anders Båtstrand
>>
>  --
> >>>>>>>>>> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      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+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to