Question about MQ

I am thinking, during summer, to use ServiceStack as the front-end HTTP API for an MS Orleans silo or cluster later. Clients will be REST/JSON or MQ/ protobuf . The thought is

  1. Some requests to be redirected to Orleans grains/actors and to send JSON or protobuf without deserialization directly to grains(they will be responsible for deserialization and they will be related to unique typed requests as the ServiceStack) , to end immediately the HTTPRequest or the MQ and
  2. then to wait from an Orleans Stream, to send responses which will be sent through websockets or SSE to clients. (the responses part is not very clear to me this very moment).
    The first issue, seems more clear, can I do it in global request filters ? or in MQ?
    The second issue, can we embed in ServiceStask a websockets feature ( or does it has already the capability) to handle the websockets? ( I suppose clients will ask from SS the websocket connection with HTTPRequest), what we can do for this issue ?
    thanks

I’m not familiar with how to call Orleans but if it provides an async API then the easiest approach is to call it in the Service implementation, e.g:

public IOrleansClient OrleansClient { get; set; } //injected

public Task<object> Any(MyRequest request) => OrleansClient.CallOrleans(ToOrleansRequest(request));

I’m using a hypothetical API as I’m assuming there’s an Orleans client you can register in IOC to call it

Otherwise if orleans is more a one-way message flow like a message queue you would return void in your Service and publish the message to Orleans:

public void Any(MyRequest request) => OrleansClient.CallOrleans(ToOrleansRequest(request));

The request would contain either the SSE SubscriptionId, Users Session Id or User Id depending on how you want the message broadcasted, e.g. single browser tab (Sub Id), all browser tabs (Session Id), same user in any browser or connected client (User Id)

Then in the Orleans implementation either use a C# Service Client or MQ Client to call back into a ServiceStack Service where it handles the response at which point you can notify the client via Server Events, e.g:

public IServerEvents ServerEvents { get; set; }

public void Any(MyRequestCallback request) => ServerEvents.NotifySubscription(request.SubId, request);

ServiceStack Server Events is integrated and works everywhere ServiceStack does, e.g. IIS/ASP.NET, Self-Hosting, .NET Core, etc. we don’t provide support for WebSockets which is server dependent.

You could use ServiceStack with SignalR in ASP.NET but they’re 2 separate independent technologies without any explicit integration.

1 Like

As I have asked about Orleans, in the meantime, there is not big delay for the responses from grains/silo. and the Orleans client is asynchronous .
So I will not decouple the HttpRequests from the Responses.
In that case it seems to me the ServiceStack Messaging API is ideal.
I will use only SSE or/and websockets, in the case that actors want to broadcast messages to clients.
The one-way message is also a special use case, and Orleans will support it next release.