Skip to content

Instantly share code, notes, and snippets.

@creepone creepone/App.config
Last active Aug 29, 2015

Embed
What would you like to do?
Remote Deathwatch - simplest example where fast restart of one client corrupts the other one.
<?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>
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
You can’t perform that action at this time.