Page History
...
Code Block | ||||
---|---|---|---|---|
| ||||
public class SomeController : ApiController { //expose your endpoint as async public async Task<SomeResult> Post(SomeRequest someRequest) { //send a message based on your incoming arguments to one of the actors you created earlier //and await the result by sending the message to `Ask` var result = await MvcApplication.MyActor.Ask<SomeResult>(new SomeMessage(someRequest.SomeArg1,someRequest.SomeArg2)); return result; } } |
WindowsService (
...
Topshelf를 이용한 윈도우 서비스화)
Info |
---|
topshelf 는 개발서비스를 단독 서비스 실행 하는데 도움이되는 툴킷입니다. ( 마이크로 서비스화에 도움이되는 부분요소) |
Code Block | ||||
---|---|---|---|---|
| ||||
using Akka.Actor; using Topshelf; class Program { static void Main(string[] args) { HostFactory.Run(x => { x.Service<MyActorService>(s => { s.ConstructUsing(n => new MyActorService()); s.WhenStarted(service => service.Start()); s.WhenStopped(service => service.Stop()); //continue and restart directives are also available }); x.RunAsLocalSystem(); x.UseAssemblyInfoForServiceInfo(); }); } } /// <summary> /// This class acts as an interface between your application and TopShelf /// </summary> public class MyActorService { private ActorSystem mySystem; public void Start() { //this is where you setup your actor system and other things mySystem = ActorSystem.Create("MySystem"); } public async void Stop() { //this is where you stop your actor system await mySystem.Terminate(); } } |
...