Orleans & OWIN: A Trivial Configuration Middleware

 

We’ve been messing around with the recently released Orleans framework and OWIN/Katana – so that we can access Orleans grains from a Web Api project.

In doing so, we’ve had the need to ensure that Orleans is actually initialized before any requests are made. The following snipped of code provides an IAppBuilder extension method which does just that, so that you can call it using app.ConfigureOrleans() in your OWIN startup configuration method.

Hope it helps :) Send any suggestions/abuse our way.

4 responses

  1. Nice and simple, I like it :) However, it fails if you lose connection to the Orleans gateway for any reason – the OrleansClient still shows IsInitialized as true, but it will forever throw “No gateway available” or something like that. I assume that it’s expected that the gateway will not be restarted as you upgrade the nodes, but it’s still a bit icky. And since the OrleansClient doesn’t post usefully filterable excpetions, and the Initialize call takes a lot of time, I’ve had to implement (simple and stupid) auto-reinit. Have you tried wrestling with the problem or do you just assume the gateway will always be on?

  2. I completely agree, Luann. That should probably be filed as a bug against Orleans, though, since that should not be handled in the application layer.

    What do you think?

  3. Luann & Reuben, looks like there is a misunderstanding here.

    TL;DR: Of course, client connection to gateways can be reliable. How would we run in production otherwise? :-)

    Without seeing your ClientConfiguration.xml I suspect it’s a copy of the local silo one that point’s to a fixed gateway address. This is simple and useful for local development and maybe for some static unreliable configuration.

    For a reliable deployment, you need to change the config to use cluster membership data as described in http://orleans.codeplex.com/wikipage?title=Client%20Configuration&referringTitle=Orleans%20Configuration%20Guide. Similarly, reliable silo configuration is documented in http://orleans.codeplex.com/wikipage?title=Server%20Configuration&referringTitle=Orleans%20Configuration%20Guide.

    When you run with the reliable configuration, client connects to all available gateways (silos), fails over to alive connections, and connects to newly started silos. In general, the client app code shouldn’t see any errors if you have at least one silo up and running at any point in time.

    Looks like this question deserves to be copied to http://orleans.codeplex.com/discussions or http://orleans.codeplex.com/wikipage?title=Frequently%20Asked%20Questions, so that other people benefit from the discussion.

    Thanks,
    -Sergey

    • Thanks, Sergey – I haven’t done any fault tolerance testing on Orleans. I have been using the proposed fault-tolerant setup and haven’t seen any problems yet.

Comments are closed.