April 2018
Intermediate to advanced
382 pages
10h 11m
English
This recipe is made up of three parts:
So once ServerMock is instantiated, it registers the SseResource class:
final ResourceConfig resourceConfig = new ResourceConfig(SseResource.class);final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(CONTEXT, resourceConfig, false);server.start();
Then two key methods from SseResource take place. The first one adds messages to the server queue:
addMessage(final String message, @Context Sse sse)
The second one consumes this queue and sends the messages to the clients:
@GET@Produces(MediaType.SERVER_SENT_EVENTS)public ...
Read now
Unlock full access