我一直在努力研究过去两天,试图找出如何将基本控制台应用程序部署到Azure辅助角色并使其具备可以从某种基于客户端的应用程序远程访问,例如MVC网络应用程序。下面的答案如何在Azure辅助角色(AKKA.NET)中配置远程参与者配置
1
A
回答
2
我开始让我的Actor状态包含在我的MVC应用程序与之通信的本地控制台应用程序中。我希望将自己的应用程序部署到Azure生态系统中,并且认为将状态维持在工作者角色之内,并在应用程序服务中托管一个思维“客户端”MVC应用程序,这将是最好的前进方向。
确保您的Actor系统从您的解决方案中解压缩到它自己的项目中。在解决方案中创建一个新的Worker角色CloudService项目。
我配置我的WorkRole如下:
public class WorkerRole : RoleEntryPoint
{
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private readonly ManualResetEvent runCompleteEvent = new ManualResetEvent(false);
private static ActorSystem ActorSystemInstance;
public override void Run()
{
Trace.TraceInformation("Game.State.WorkerRole is running");
try
{
this.RunAsync(this.cancellationTokenSource.Token).Wait();
}
finally
{
this.runCompleteEvent.Set();
}
}
public override bool OnStart()
{
ActorSystemInstance = ActorSystem.Create("GameSystem");
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at https://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
Trace.TraceInformation("Game.State.WorkerRole has been started");
return result;
}
public override void OnStop()
{
ActorSystemInstance.Terminate();
Trace.TraceInformation("Game.State.WorkerRole is stopping");
this.cancellationTokenSource.Cancel();
this.runCompleteEvent.WaitOne();
base.OnStop();
Trace.TraceInformation("Game.State.WorkerRole has stopped");
}
private async Task RunAsync(CancellationToken cancellationToken)
{
var gameController = ActorSystemInstance.ActorOf<GameControllerActor>("GameController");
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
await Task.Delay(1000);
}
}
}
而且我HOCON文件(在app.config内)如下:
<akka>
<hocon>
<![CDATA[
akka {
loglevel = DEBUG
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
remote {
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
transport-protocol = tcp
enforce-ip-family = true
port = xxxx //the port configured in your worker role endpoint
hostname = "0.0.0.0" //This is the local hostname of the worker role, using 0.0.0.0 will set the Remote actor to "listen" on all available DNS/IP addresses including the loopback (127.0.0.1)
pulic-hostname = "xx.xx.xx.xx" //IP Address OR DNS name, but whatever is set here is what MUST be used in the Actor Selector path on the client in order for proper "association" to occur. I did find that DNS name was required for my application as I was using SignalR as a bridge between the Actor system and the web client.
}
}
}
]]>
</hocon>
我们需要在工作人员角色配置中定义我们的端点,以便我们“暴露”我们可以与外界沟通的端口。所以去你的WorkerRole设置。
一旦工作者角色部署,你应该能够确认该端口是telnet'ing到服务器开放和可用通过它的IP和端口,你以前配置。
与我们的客户设置我们ActorSelection最重要的部分是IP/DNS地址如下必须匹配与IP/DNS辅助角色
ActorReferences.GameController =
ActorSystem.ActorSelection("akka.tcp://[email protected]:8091/user/GameController")
.ResolveOne(TimeSpan.FromSeconds(3))
.Result;
内的公共主机名设置中设置的HOCON配置
为了完整这里是我的客户HOCON配置:
akka {
loglevel = OFF
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
remote {
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
transport-protocol = tcp
enforce-ip-family = true
port = 0 //A port will be provided for us... not important as we won't be calling into the client externally
public-hostname = "yoursitename.azurewebsites.net" //Remember this is simply the DNS name of the client machine
hostname = "127.0.0.1"
}
}
}
我真的希望这可以帮助别人那里。我没有发现很多描述Azure的部署到Azure的文档(没有将Actor系统部署到易失性的IIS应用服务)。让我知道我是否可以以任何方式改进答案。
相关问题
- 1. 使用Azure辅助角色进行配置文件转换
- 2. Azure角色配置管理
- 3. 的Azure的辅助角色
- 4. 配置git辅助回购
- 5. Azure工作者角色忽略ServiceConfiguration.Local配置
- 6. 如何在Azure辅助角色中使用证书?
- 7. 如何配置ParsleyJs远程
- 8. 无法从Azure的辅助角色
- 9. 从辅助角色使用Azure Cmdlet
- 10. 如何在辅助角色上设置计时器?
- 11. 在Windows Azure角色之间共享配置设置
- 12. Akka.Net的完整HOCON配置
- 13. Akka.net:访问群集中的远程参与者
- 14. 如何在本地/内部托管Azure辅助角色?
- 15. 解析配置远程配置文件
- 16. Azure在角色缓存中的缓存主机配置
- 17. iOS远程配置?
- 18. Firebase远程配置
- 19. 从远程配置
- 20. 是否使用辅助角色或Web角色:Windows Azure的
- 21. Azure的辅助角色:获取Web角色
- 22. 如何配置kie-workbench的角色7.0.0
- 23. 使用SlowCheetah和自定义配置时的Azure Worker角色配置问题
- 24. 在Windows Azure中配置SSL
- 25. 如何使用PowerShell远程配置IIS?
- 26. 如何配置atom.io远程ftp包
- 27. Azure DSC配置
- 28. 如何从Azure配置文件获取所有配置设置?
- 29. 如何使用配置文件改进rails辅助方法?
- 30. 在单个Azure云服务上部署多个Web角色和辅助角色