These are chat archives for petabridge/akka-bootcamp

Jul 2017
Jul 12 2017 10:12

Here's an example. I like to ask my actor for a magic-string. This code is outside of an actor. Good old OOP class.

var magicString = await magicStringActor.Ask<MagicStringResponse>(new MagicStringRequest(), TimeSpan.FromSeconds(1)).Result.MagicString;

Then I have a MagicStringActor with a Handle() method like this

public void Handle(AkkaTest.MagicStringRequest message)
            var t = Task.Run(async () =>
                 var t1 = _otherActor.Ask<MagicStringResponse>(message, TimeSpan.FromSeconds(1));

                 await Task.WhenAll(t1);

                 return new Result<AkkaTest.MagicStringResponse>(t1.Result);

            t.PipeTo(????, Self); //What to do here? How would I get my result back to the initial Ask()?

This actor may or may not ask other actors for the magic string. But what to do with the result? I can pipe it to other actors. But how do I return the result or the resulting task to my code outside the actor?

Aaron Stannard
Jul 12 2017 14:24
@KingKnecht ah
you just need to reply to the Sender
and that will complete the Task
Jul 12 2017 17:42
Cool. Thx!