Skip to content

Instantly share code, notes, and snippets.

View Danthar's full-sized avatar

Arjen Smits Danthar

  • The Netherlands
View GitHub Profile
@Danthar
Danthar / gist:5e2812d3d6ca31129c01
Last active August 29, 2015 14:23
Router supervisionstrategies
using System;
using Akka.Actor;
using Akka.Routing;
namespace Akka.RouterStrategies
{
class Program
{
static void Main(string[] args) {
var system = ActorSystem.Create("failboat");
2015-07-08 14:10:41.588 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b/processor to akka://Importer/user/stamdata/importRouter/$b/processor was not delivered. 1 dead letters encountered."
2015-07-08 14:10:41.589 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b to akka://Importer/user/stamdata/importRouter/$b was not delivered. 2 dead letters encountered."
2015-07-08 14:10:41.589 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b/processor/database to akka://Importer/user/stamdata/importRouter/$b/processor/database was not delivered. 3 dead letters encountered."
2015-07-08 14:10:41.590 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b to akka://Importer/user/stamdata/importRouter/$b was not delivered. 4 dead letters encountered."
2015-07-08 14:10:41.591 +02:00 [Information] "Message DeathWatchNo
public abstract class BackoffProtocol
{
/// <summary>
/// I made the TrackedMsg generic so you wont have to do manual matching in your child actor.
/// Downside is, that it limits your communication options with the child actor.
/// </summary>
/// <typeparam name="T"></typeparam>
[Serializable]
public sealed class TrackedMsg<T>
{
class AskAggregator<TReq, TRep> : ReceiveActor
{
public AskAggregator(IActorRef askFor, IActorRef replyTo, IEnumerable<TReq> items)
{
var requestCount = items.Count();
var replies = new HashSet<TRep>();
foreach (var request in items)
askFor.Tell(request);
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka"/>
</configSections>
<akka>
<hocon>
akka {
stdout-loglevel = DEBUG
public static class SerializerTestHelpers
{
public static async Task<T> AkkaSerialized<T>(this T src)
{
var hocon = "akka.actor.provider = \"Akka.Remote.RemoteActorRefProvider, Akka.Remote\"" +
Environment.NewLine +
"akka.remote.helios.tcp.port = 0" + Environment.NewLine +
"akka.remote.helios.tcp.hostname = localhost";
var sys = ActorSystem.Create("src");//, ConfigurationFactory.ParseString(hokon));
await sys.Terminate();
@Danthar
Danthar / cluster config TraderActor SM host
Created May 26, 2017 10:16
Akka.net cluster singleton example
cluster {
seed-nodes = ["akka.tcp://TradingRoomActors@localhost:8083"]
roles = ["traderworker"]
singleton {
singleton-name = "TraderActor"
role = "traderworker"
hand-over-retry-interval = 1s
}
singleton-proxy {
singleton-name = "TradesActor"
@Danthar
Danthar / gist:30ee6133294e3f1a85dcd5bc948fc625
Last active August 31, 2017 13:53
EventAdapters Persistence review based on changes
Premise:
We need an extra manifest column for EventAdapters. Because SerializerWithStringManifest type serializers are not compatible.
Findings:
EventAdapters are registered via an ActorSystem extension. And they are utilised based on an type -> adapter mapper. Which means if you want to utilise them you have to provide a mapping for the message type you want to use it on. Same concept as how serialization-bindings work.
EventAdapters are layered in the persistence system. Like a layer of a sandwich :P.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);PackReferencedProjectOutputs</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
// we put this target in an props file and import it
<Target Name="PackReferencedProjectOutputs" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);PackReferencedProjectOutputs</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
// we put this target in an props file and import it
<Target Name="PackReferencedProjectOutputs" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />