I'm trying to create a very basic example of using SSE + CDI events. To do
that, I created a basic endpoint based on a CXF systest that I found, but
tried to adapt it to work with CDI.
@Path("/sse")
@RequestScoped
public class SseEventEndpoint {
@Inject
private Event<SseEvent> event;
@Context
private Sse sse;
@GET
@Path("{connectionId}")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void onEvent(@Context SseEventSink sink,
@PathParam("connectionId") final String id) {
System.out.println("Received request "+sse);
event.fireAsync(new SseEvent(sink, sse, id));
}
}
However, no matter what I do, the Sse object is null. Is there something I
need to do to enable Sse integration? This is what my dependencies look
like
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-integration-cdi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-sse</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>