Does Dropwizard support Servlet 3 asynchronous servlets? If not, is it on the roadmap at any time in the near future?
It uses Jetty 8, which supports Servlet 3.0. Jersey (and JAX-RS) doesn't have any support for this, but it's forthcoming in JAX-RS 2.0 (and Jersey 2.0). Dropwizard doesn't add anything special, but when Jersey 2.0 ships, the next major Dropwizard release will very likely include it.
You can use https://github.com/jetty-project/jetty-eventsource-servlet. Read wiki for how to impl Servlet and EventSource
In your DW Service implementation you add your SSE servlet
environment.addServlet(new MySseEventSourceServlet(), "/sse");
Then add this to your DW config
http:
connectorType: NONBLOCKING
now you can start listening for Server-sent Event's on
<host>:<port>/sse
ex.
curl localhost:8080/sse -H"Accept: text/event-stream"
See working example @ GitHub, https://github.com/andershedstrom/dropwizard-with-sse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With