Last active
August 29, 2015 14:27
-
-
Save creepone/080165a934b04379ef8b to your computer and use it in GitHub Desktop.
Remote Deathwatch - simplest example where fast restart of one client corrupts the other one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<configSections> | |
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" /> | |
</configSections> | |
<startup> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | |
</startup> | |
<appSettings> | |
<add key="RemoteSystem" value="akka.tcp://Test@127.0.0.1:58411" /> | |
</appSettings> | |
<akka> | |
<hocon> | |
<![CDATA[ | |
akka { | |
actor { | |
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote" | |
} | |
remote { | |
helios.tcp { | |
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote" | |
transport-protocol = tcp | |
hostname = "127.0.0.1" | |
port = 58410 | |
} | |
} | |
} | |
]]> | |
</hocon> | |
</akka> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Configuration; | |
using System.Threading; | |
using Akka.Actor; | |
namespace RemoteDeatchwatch | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var actorSystem = ActorSystem.Create("Test"); | |
var dummyActor = actorSystem.ActorOf(Props.Create<DummyActor>(), "dummy"); | |
var remoteCounterpartAddress = string.Format("{0}/user/dummy", ConfigurationManager.AppSettings["RemoteSystem"]); | |
Thread.Sleep(20000); | |
// simulate our dummy talking to the remote dummy | |
actorSystem.ActorSelection(remoteCounterpartAddress).Tell(new DummyActor.Init(), dummyActor); | |
Console.ReadLine(); | |
actorSystem.Shutdown(); | |
} | |
} | |
public class DummyActor : ReceiveActor | |
{ | |
public DummyActor() | |
{ | |
Receive<Init>(_ => | |
{ | |
Console.WriteLine("Deathwatch starting."); | |
Context.Watch(Sender); | |
}); | |
Receive<Terminated>(terminated => | |
{ | |
Console.WriteLine("Peer terminated."); | |
}); | |
} | |
public class Init | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment