Sending Akka.net cluster gossip to Azure worker role console

三世轮回 提交于 2019-12-06 14:04:03

问题


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?


回答1:


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:



来源:https://stackoverflow.com/questions/34002993/sending-akka-net-cluster-gossip-to-azure-worker-role-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!