Skip to content

Instantly share code, notes, and snippets.

View Danthar's full-sized avatar

Arjen Smits Danthar

  • The Netherlands
View GitHub Profile
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();
<?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
@Danthar
Danthar / gist:7580931
Created November 21, 2013 12:43
Javascript shim to properly add bootstrap 3 styling to validation helpers et al in asp.net MVC 4
$(function () {
$('span.field-validation-valid, span.field-validation-error').each(function () {
$(this).addClass('help-block col-xs-12 col-sm-reset inline');
});
$('.validation-summary-errors').each(function () {
$(this).addClass('alert');
$(this).addClass('alert-error');
$(this).addClass('alert-block');
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);
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
@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");
@Danthar
Danthar / Throttler.cs
Created June 18, 2015 10:45
Basic throttler
//Usefull for consumer/producer processing where you keep track of how many work you have served up in the producer
//and call Wait with that amount
//then consumer will call Hit to signal some work has been completed.
//producer will block on Wait until consumer has catched up
public class Throttler {
private AutoResetEvent resetEvent = new AutoResetEvent(false);
private int counter;
private int throttleAmount;
@Danthar
Danthar / gist:12f1b2dd229d4e58927a
Created June 8, 2015 13:49
Start werkzaamheden - command based - vanaf scratch poc
public class WerkbonAggregate {
private WerkbonModel _state;
private List<object> _uncommittedEvents = new List<object>();
public WerkbonAggregate(WerkbonModel state) {
_state = state;
}
public void StartWerkzaamHeden(DateTime gestartOp){
@Danthar
Danthar / gist:5c44f93e65706467cc46
Created May 8, 2015 11:49
Simple akka supervision and retry with IUnboundedStash example
class Program
{
static void Main(string[] args) {
var system = ActorSystem.Create("failboat");
var actor = system.ActorOf(Props.Create(() => new ParentActor()));
actor.Tell(5); //this will fail
actor.Tell("This message will work");
@Danthar
Danthar / gist:594d08dc26bc36cfab34
Created April 24, 2015 06:42
Consume RabbitMq messages with Akka : Part 2
//this is with the easynetq librabry but could just as easily be anything else.
rabbitBus.Subscribe<MyMessageType>(subscriptionId, message => {
Log.Debug("message from rabbitmq received");
//this works! because of how Ask works (it creates a fake actor that is passed as sender behind the scenes)
var result = workers.Ask<WorkCompleted>(new StartWorkFor() {Details = message}).Result;
});
//however this...