Search code examples
azureazure-worker-rolesakka.netakka.net-cluster

Sending Akka.net cluster gossip to Azure worker role console


I'm developing an Azure cloud service including multiple worker roles that form an akka.net cluster. How do I accomplish getting the cluster gossip and other messages end up in the compute emulator console windows?


Solution

  • At the moment I'm working on an Akka.NET cluster that will be hosted as Azure Cloud Services and ran into the same problem.

    The quickest way I found to accomplish this is to write a logging adapter (though I' still relatively new to Akka.NET, so take this advice with a pinch of salt). Here's the basic one I'm using for now:

    public class ComputeEmulatorConsoleLogger : ReceiveActor
    {
        public ComputeEmulatorConsoleLogger()
        {
            Receive<InitializeLogger>(_ =>
            {
                Trace.WriteLine("Compute emulator console logger started.");
                Sender.Tell(new LoggerInitialized());
            });
    
            Receive<LogEvent>(ev =>
            {
                Trace.WriteLine(ev.ToString());
            });
        }
    }
    

    And in the akka HOCON configuration section add the class' path and assembly name, for example:

    loggers = [ "WorkerRole2.ComputeEmulatorConsoleLogger,WorkerRole2" ]
    

    It's not perfect, but as you can see it works well enough so you're not pulling your hair out wondering what the actor system is up to:

    Screenshot