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
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); |
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
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> | |
{ |
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
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 |
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.Routing; | |
namespace Akka.RouterStrategies | |
{ | |
class Program | |
{ | |
static void Main(string[] args) { | |
var system = ActorSystem.Create("failboat"); |
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
//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; |
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
public class WerkbonAggregate { | |
private WerkbonModel _state; | |
private List<object> _uncommittedEvents = new List<object>(); | |
public WerkbonAggregate(WerkbonModel state) { | |
_state = state; | |
} | |
public void StartWerkzaamHeden(DateTime gestartOp){ |
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
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"); |
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
//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... |
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; | |
namespace AkkaAsyncAwait | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var system = ActorSystem.Create("MySystem"); |
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
coordinatorActor.Ask<string>(new JuleeDoTheThing()); | |
//meanwhile in the coordinatorActor.. | |
//.. | |
Receive<JuleeDoTheThing>(message => { | |
_askParent = Context.Sender; | |
childActor.Tell(new DoSomething()); |