Last active
August 10, 2016 19:29
-
-
Save trbngr/81541dd481a564cee2617af00cc058c1 to your computer and use it in GitHub Desktop.
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.2" /> | |
</startup> | |
<akka> | |
<hocon> | |
<![CDATA[ | |
akka { | |
loglevel = DEBUG | |
actor { | |
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster" | |
serializers { | |
wire = "Akka.Serialization.WireSerializer, Akka.Serialization.Wire" | |
} | |
serialization-bindings { | |
"System.Object" = wire | |
} | |
} | |
remote { | |
helios.tcp { | |
public-hostname = "localhost" | |
hostname = "localhost" | |
port = 0 | |
} | |
} | |
cluster { | |
sharding { | |
role = "projections" | |
least-shard-allocation-strategy.rebalance-threshold = 3 | |
} | |
seed-nodes = [ | |
"akka.tcp://eventdayprojections@168.62.228.228:4053", | |
"akka.tcp://eventdayprojections@23.96.183.175:4053" | |
] | |
roles = ["projections"] | |
} | |
persistence { | |
journal { | |
plugin = "akka.persistence.journal.sqlite" | |
sqlite { | |
connection-string = "Data Source=.\\store.db;Version=3;" | |
auto-initialize = true | |
} | |
} | |
snapshot-store { | |
plugin = "akka.persistence.snapshot-store.sqlite" | |
sqlite { | |
connection-string = "Data Source=.\\store.db;Version=3;" | |
auto-initialize = true | |
} | |
} | |
} | |
} | |
]]> | |
</hocon> | |
</akka> | |
<runtime> | |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
<dependentAssembly> | |
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-1.0.102.0" newVersion="1.0.102.0" /> | |
</dependentAssembly> | |
</assemblyBinding> | |
</runtime> | |
</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 Akka.Actor; | |
using Akka.Cluster.Sharding; | |
using Akka.Cluster.Tools.Singleton; | |
using Akka.Configuration; | |
namespace ConsoleApplication1 | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var config = ConfigurationFactory.Load().WithFallback(ClusterSingletonManager.DefaultConfig()); | |
using (var system = ActorSystem.Create("eventdayprojections", config)) | |
{ | |
var region = ClusterSharding.Get(system).Start( | |
"temp", | |
Props.Create<ProjectionActor>(), | |
ClusterShardingSettings.Create(system), | |
new MessageExtractor() | |
); | |
string message; | |
while (Continue(out message)) | |
{ | |
region.Tell(message); | |
} | |
} | |
} | |
private static bool Continue(out string message) | |
{ | |
message = null; | |
var key = Console.ReadKey(); | |
if (key.Key == ConsoleKey.X) | |
return false; | |
message = key.KeyChar.ToString(); | |
return true; | |
} | |
} | |
internal sealed class MessageExtractor : HashCodeMessageExtractor | |
{ | |
public MessageExtractor() : base(300) | |
{ | |
} | |
public override string EntityId(object message) | |
{ | |
return message as string; | |
} | |
} | |
internal class ProjectionActor : ReceiveActor | |
{ | |
public ProjectionActor() | |
{ | |
Receive<string>(s => Console.WriteLine($"Received: {s}")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment