title: Server-Sent Events in Restlet 2.3 Framework - Is It Possible?
body: <p>Good day everyone!</p>
  
  <p>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 <code>ServerResource</code>:</p>
  
  <ul>
  <li>there should be a way to create an <em>endless</em> representation, so that the framework wouldn't wait until the <code>ServerResource</code> instance finish filling it, but send it to the client by portions. I've found <code>WritableRepresentation</code> or <code>AppendableRepresentation</code> classes in the Restlet documentation - their names look similar to what is needed, but there are not examples of their usage;</li>
  <li>this <em>endless</em> 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;</li>
  <li>I have to set "text/event-stream" media type for the representation, which is not in the <code>Media</code>'s possible values.</li>
  </ul>
  
  <p>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 <a href="https://github.com/restlet/restlet-framework-java/wiki/Road-map-of-version-3" rel="nofollow">Restlet 3.0</a>.</p>
  
  <p>Is it possible in the Restlet 2.3 with some workarounds?</p>
  
  <p>If it is not, what Java framework for standalone RESTful services would you recommend?</p>
  
  <p>Thank you.</p>