Hi,

I have a question about the Server Sent Events mechanism.
I migrated a few projects from Jersey to the Aries JAX-RS Whiteboard
implementation and there is now a question about the specification at
all.

There is an example in the specification that demonstrates the use of
Server Sent Events in the specification.
https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html#d0e133342

Instead of a Response object this example returns "void".

There is a REST endpoint that is marked to  produce SSE.
First it checks some stuff.
On failure a response "not found" (or another one e.g. "bad request")
is returned.
On success the "SseEventSink" is used to write events.
If writing of an event throws an exception the event sink is closed.

To return "not found" I currently use an argument "@Context
HttpServletResponse response".
response.setStatus(Status.NOT_FOUND.getStatusCode());
After setting this status the method returns.
Is this okay or do I need to write a not found web application exception?
If I set the status and return, do I also need to close the event sink?
If I throw a web application excpetion, to I need to close the event
think explicit?
If some of mine code throws a runtime exception (e.g. NPE), must I
ensure the event sink is closed or should this be handled by the
whiteboard implementation?

On success, I want to inject additional headers. For example
"X-Accel-Buffering: no" and "Content-Encoding: identity".
Currently I am using "reponse.addHeader(..., ...)", too.
Can I also change the method signatur and return a Response object?
Should this be considered by the whiteboard implementation?
That way I could return e.g.
"Response.status(Status.NOT_FOUND).build()" or
"Response.ok().header(..., ...).header(..., ...).build()".

I am using an implementation of a "ContainerResponseFilter". It is
marked with "JaxrsExtension" annotations etc. and works for all my
REST endpoints.
Except for the SSE one...
Currently the implementations checks if the component is configured to
allow CORS and if allowed it adds headers to the response context.
Should such a container response filter be considered for endpoints
producing SSE or not?

Best regards,
Markus
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to