Server-Sent Events in Restlet 2.3 Framework - Is It Possible?

297 Views Asked by At

Good day everyone!

I'm trying to use Restlet 2.3 framework to provide RESTful API in a standalone JavaSE application. The problem is that RESTful API I have to provide contains a resource that is represented by a server-sent events stream. I am a Restlet neophyte and cannot say I fully understand its internals, but I see three problems regarding implementation of SSE as Restlet's ServerResource:

  • there should be a way to create an endless representation, so that the framework wouldn't wait until the ServerResource instance finish filling it, but send it to the client by portions. I've found WritableRepresentation or AppendableRepresentation classes in the Restlet documentation - their names look similar to what is needed, but there are not examples of their usage;
  • this endless reresentation should probably be managed by the framework in some other way. I can make a thread that would append new events to that representation, but all (?) the request-processing resources of the framework should be released;
  • I have to set "text/event-stream" media type for the representation, which is not in the Media's possible values.

I've done a small internet research on this topic and found that implementation of the SSE for Restlet was one of the ideas for this year's GSoC (may be wrong, the link is lost). I also found that this feature is planned for Restlet 3.0.

Is it possible in the Restlet 2.3 with some workarounds?

If it is not, what Java framework for standalone RESTful services would you recommend?

Thank you.

0

There are 0 best solutions below