public void onReceive(Object message) throws Exception {
final ActorRef sender = sender();
Future f = ...;
f.onComplete(new OnComplete() {
@Override
public void onComplete(Throwable throwable, Object object) throws Throwable {
// Can use final sender here.
// What actor methods are allowed here?
}
}, context().dispatcher());
}
--
>>>>>>>>>> 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.
--
>>>>>>>>>> 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.
On 22 Sep 2015, at 14:20, John Ulric <uja...@gmail.com> wrote:
@Heiko, @Roland, thanks. The callback in my case essentially makes a decision where to send the future result (to self, to a delegee actor, to the calling actor) plus some error handling, logging and monitoring, so it is a pipe, essentially. I found the code more readable when I make these decisions here in the callback, instead of piping the result to self, making the decisions, and forwarding the message again. Do you think this is an acceptable pattern or would you absolutely discourage to the use of a callback here?
@Heiko, @Roland, thanks. The callback in my case essentially makes a decision where to send the future result (to self, to a delegee actor, to the calling actor) plus some error handling, logging and monitoring, so it is a pipe, essentially. I found the code more readable when I make these decisions here in the callback, instead of piping the result to self, making the decisions, and forwarding the message again. Do you think this is an acceptable pattern or would you absolutely discourage to the use of a callback here?
--
>>>>>>>>>> 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.
--
>>>>>>>>>> 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.
Good point. I think you are spot on here -- this would be a minefield in practice, even more so than occasionally forgetting not to use Futures inside Actors.I hadn't thought about switchable Actor behaviors.
Patterns.pipe(Patterns.ask(otherActor, message, timeout), context().dispatcher());
If yes, what's the way if I want to wrap the ask result to add some information for subsequent processing that the otherActor cannot do? Would it be OK to call something like this?
Patterns.pipe(Patterns.ask(otherActor, message, timeout).map(new Mapper<Object, Object>() {
@Override
public Object apply(Object parameter) {
return new WrappedMessage(message, otherImmutableParameter);
}
}, context().dispatcher()), context().dispatcher());
Or does using the future's map method again violate the "don't use future callbacks in actors" rule?otherActor.tell(message, targetActor);--
>>>>>>>>>> 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.