These are chat archives for petabridge/akka-bootcamp

4th
Nov 2016
Daniel Santa Cruz
@dstcruz
Nov 04 2016 17:03
Quick question: when an actor restarts (i.e. because it threw an exception), do any monitoring actors get notified that the actor died?
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 18:54
if you want to catch the exception, you can override the SupervisorStrategy function on the supervising actor
if you want the context (which child actor died and the exception), you can have a Failure class receiver on the supervising actor
its in unit 1 lesson 4 in the bootcamp
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:14
Does anyone have a sample of using Become in f#?
I've tried: mailbox.Context.Become (myOtherActor someParameters)
where: myOtherActor is
let myOtherActor (param:string) (mailbox:Actor<_>) = ...
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:22
I'll ask the mailing list. I didn't know where it was.
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 19:23
i dont use f#, sorry
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:23
well, maybe you can help me understand something. I think it should work the same in c#
So, I have an actor which does TCP. Problem is that when that actor dies, the parent restarts it, and it creates a new tcp connection.
Since it was "restarted" the system TCP actor never saw my TCP client's death, and therefore doesn't close the old TCP connection.
Is there a pattern somewhere that I should be using for this?
I can't seem to find info on it. My google-foo is not strong today.
I guess I can try to send a TCP.Close in mailbox.Defer
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 19:26
maybe you can try Akka.IO instead?
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:26
Yes, that's what I'm trying.
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 19:26
ah...
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:28
so I do a Tcp.Register from my actor. But, when my actor dies... parent restarts (which should happen), but the TCP (system) actor that is associated with my actor does not see the restart, and therefore I don't know not to run Tcp.Register (and Tcp.Connect) again.
... and I have no reference to the old TCP (system) actor anyway anymore.
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 19:32
the bind should happen automatically when the actor is restarted?
i've never actually use akka.io myself, you're saying that the socket connection didn't automatically close when the actor died?
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 19:38
oh, right, i think i get what you're saying.. you want a reference to the TCP listener that's actually listening to the port...
i guess you can store a reference to it inside the Tcp.Bound Receive, and kill it when you hit an exception
ie. inside the Receive<Tcp.Bound>(), you store the IActorRef of the Sender in that particular Context, and send a PoisonPill message to it when you hit an exception, then you can do another bind
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:41
Thanks, I'll give that a shot.
Gregorius Soedharmo
@Arkatufus
Nov 04 2016 19:42
hope that works, good luck
Daniel Santa Cruz
@dstcruz
Nov 04 2016 19:42
yeah, me too! :)