The JAX-RS 2.1 introduced the support of server-sent events (SSE). Although SSE in general works on top of HTTP transport, the SSE implementation in CXF uses the dedicated one, based on Atmosphere framework. This transport only required on the server-side (client side works over normal HTTP) and is fully compatible with HTTP transport.


There are several ways to configure SSE transport (and as the consequence, SSE support). The most straightforward one is to pass the init parameter "transportId" to the CXF servlet in question, for example:

final CXFNonSpringServlet cxfServlet = new CXFNonSpringServlet();
final ServletHolder holder = new ServletHolder(cxfServlet);
holder.setInitParameter(CXFCdiServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID);

In this case the JAXRSServerFactoryBean instances should also specify the SSE transport during construction time, for example:

final JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint(<application>, JAXRSServerFactoryBean.class);
return factory.create();

Advanced Configuration

Since Apache CXF 3.2.3 release, it is possible to use alternative means to configure transports, including SSE one, by passing it through the Bus property "" (also available as AbstractTransportFactory.PREFERRED_TRANSPORT_ID constant). With this property set to preferred transport, CXF servlet in question is going to pick it up instead of using the default one. SSE implementation benefits from that and in many cases setting the "transportId" init parameter on the servlet level could be omitted.