Creating Reactive Services using Servicestack and Server Events

I am trying to create reactive Service using Servicestack and Serversent Events. The thing I was doing is I post message to service. And directly push that message to actor. That is post only non blocking agent. Currently I am using F# actor but can be AKKA or any other. And then return accepted status code.

And from that I wanted to push processed message to Server Events. That eventually reach client in pushed fashion. I was trying to use Chat demo as reference but couldn’t quite make it work the server event part.

So, here are the queries

  • Am I on a right path to create reactive services?
  • Is there any good reference I can user other than chat or any suggestion to complete this reactive circle?

Let me know if anything is not clear or required more details.

Not sure I see why it needs to go through Server Events? SSE is essentially for providing server push events over HTTP.

I’d personally take the most direct possible, i.e. is there a reason why you can’t call the F#/Akka service directly? or whether the F#/Akka library can’t call ServiceStack services directly?

No, I can call. But the thing I wanted to achieve is user should not wait for processed message. And if connection is open for user it will receive pushed event from server whenever data is ready. I don’t want to block user for reply. So, I feel like SSE would be better option. Just create something like It is created with SingleR, AFAIK and I was trying to do with SSE.

I’d need to see a concrete example, but I wouldn’t think SSE is the optimal choice for server side communication.

You can just use the async API’s to avoid blocking.

@mythz Hi, I just made it work. Details are here . Do have a look. Will love to know and other servicestack user’s view on this one.

Cool, FYI a short-hand for resolving a dependency is HostContext.Resolve<IServerEvents>() seems you could avoid the SSE module completely with just:

HostContext.Resolve<IServerEvents>().NotifyAll({HelloResponse.Result = reversed})

Also never used AKKA before, but where is AKKA being used in this example?

@mythz AKKA is not being used. I am using more traditional / conventional actor. Basic one that is in built language feature of F#.

I m planning big Servicestack + AKKA blog for

Thanks for short hand. I ll update the code tomorrow. But for second part NotifyAll(Object) is extension method that I can’t use without using open Servicestack and I was facing issue with async keyword. So, just to make it work I wrap it with module.

1 Like