如何在 Meecrowave 中启用 SSE?

How to enable SSE in Meecrowave?

如何在 Meecrowave (1.2.4) 中启用 SSE?

我添加了对 org.apache.cxf:cxf-rt-rs-sse:3.2.7 的依赖,但我在资源方法中得到了 NPE:

java.lang.NullPointerException: null
at org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.impl.AsyncResponseImpl.<init>(AsyncResponseImpl.java:68) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.sse.SseEventSinkContextProvider.createContext(SseEventSinkContextProvider.java:47) ~[cxf-rt-rs-sse-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.sse.SseEventSinkContextProvider.createContext(SseEventSinkContextProvider.java:35) ~[cxf-rt-rs-sse-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.utils.JAXRSUtils.createContextValue(JAXRSUtils.java:1146) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:874) ~[cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:808) [cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214) [cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78) [cxf-rt-frontend-jaxrs-3.2.7.jar:3.2.7]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-core-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [cxf-rt-transports-http-3.2.7.jar:3.2.7]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225) [cxf-rt-transports-http-3.2.7.jar:3.2.7]

我在 Meecrowave 中找到了关于 SSE 的旧线程:

http://mail-archives.apache.org/mod_mbox/openwebbeans-user/201802.mbox/%3C147540348.1079544.1517463170730%40mail.yahoo.com%3E

但它现在似乎不相关,因为 SSE 在 CXF 3.2.5 中进行了重构:

http://cxf.apache.org/docs/sse.html

我发现有没有 asyncSupported=true 的 ServletFilter。在我将 Filter 上的 asyncSupported 设置为 true 后,它起作用了。