Steve W.
Steve W.

Reputation: 413

How can I use the service fabric actor model from MVC project?

I used the stateful actor template in visual studio 2015 to create a service fabric service. In the same solution I created an MVC app and in the about controller I attempted to copy the code from the sample client. When I run the web app and execute about action it just hangs. I don't get an exception or anything that indicates why it didn't work. Running the sample client console app where I got the code works just fine. Any suggestions on what may be wrong?

        public ActionResult About()
    {
        var proxy = ActorProxy.Create<IO365ServiceHealth>(ActorId.NewId(), "fabric:/O365Services");

        try
        {
            int count = 10;
            Console.WriteLine("Setting Count to in Actor {0}: {1}", proxy.GetActorId(), count);
            proxy.SetCountAsync(count).Wait(); /* Hangs here */

            Console.WriteLine("Count from Actor {0}: {1}", proxy.GetActorId(), proxy.GetCountAsync().Result);
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0}", ex.Message);
        }

        ViewBag.Message = "Your application description page.";

        return View();
    }

Upvotes: 0

Views: 445

Answers (1)

charisk
charisk

Reputation: 3190

Is the MVC app hosted within Service Fabric? If not then it won't be able to access Service Fabric information unless it's exposed in some way (e.g. through an OwinCommunicationListener on a service).

Upvotes: 1

Related Questions