简体   繁体   中英

How do I extend class derived from StatelessService in Service Fabric ASP.NET 5 - based service?

Is there a way to subscribe to an actor event from ASP.NET 5 - based service? I saw similar feature in service-fabric-dotnet-data-streaming-websockets sample, but the sample uses OWIN-based web service and it has PublicGateway class derived from StatelessService where one can hook to the service Task RunAsync override. I haven't found any StatelessService -derived type in the ASP.NET 5 - based project code. Seems like it's auto-generated, if to look into the project ServiceManifest.XML?

The goal I'm trying to achieve is the same with the sample - I want to subscribe to events from actor service to publish them through SignalR hub.

The difference you're seeing is that the OWIN (Katana, to be precise) sample is a Service Fabric Reliable Service - a service written on the Service Fabric API - that uses Katana to open an HTTP listener. The ASP.NET 5 (now called ASP.NET Core 1) project you're seeing is what we call a "Guest Host" which is a separate EXE hosted by Service Fabric but doesn't implement any of the Service Fabric APIs. The reason it's done this way currently is because the current ASP.NET Core 1 hosting model makes it difficult to open a web server programmatically like we do with Katana.

However, this is changing. The upcoming RC2 of ASP.NET Core 1 will let you easily start a web server programmatically, similar to the way we do it with Katana, so you can write a service on the Service Fabric API and open an ASP.NET Core 1 server from the service. Here is an example using the RC2 build: https://github.com/weidazhao/Hosting

That said, you don't necessarily need to be inside a Reliable Service to hook into actor events. Any code running in the cluster can do it by pulling in the Reliable Actors NuGet package (Microsoft.ServiceFabric.Actors) and using the ActorProxy API. You can do this in a Guest Host service, you just won't have RunAsync as an entry point to do it in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM