Hi Markus,

at first the SseEventSink is auto-closable. It can also be closed from a client side

https://javaee.github.io/javaee-spec/javadocs/javax/ws/rs/sse/SseEventSink.html

So in the examples from chapter 9.3 the usage of the sink is put in an try-statement, which auto-closes auto-closables ;-).

https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

From that point the user has to close the connection. You are fine then using the catch clause to capture exceptions.


Regarding the "ContainerResponseFilter" thing, I would expect that the filter is called for the initial response. But I never tried that out. I only found that:

https://nomanabbasi.wordpress.com/2018/07/30/jersey-2-x-server-sent-event-with-angular-6/

Mark

Am 23.01.20 um 13:30 schrieb Markus Rathgeb:

Hi Marc,

thank you foryour response.

I checked the specification I found here:
https://download.oracle.com/otndocs/jcp/jaxrs-2_1-final-eval-spec/index.html

Please allow me to add two further questions here. I agree that it is
not really OSGi related, but I assume you can give me the answer. ;)

The chapter 9.5 "Processing Pipeline" contains:
"For compatibility purposes, implementations MUST initiate processing
of an SSE response when either thefirst message is sent or when the
resource method returns, whichever happens first."

Okay so far.

"The initial SSE response,which may only include the HTTP headers, is
processed using the standard JAX-RS pipeline as described in Appendix
C. Each subsequent SSE event may include a different payload and thus
require the use of aspecific message body writer. Note that since this
use case differs slightly from the normal JAX-RS pipeline,
implementations SHOULD NOT call entity interceptors on each individual
event (1)."

So, the initial(!) response is processed as described in Appendix C...
If my understanding of Appendix C is correct, the
"ContainerResponseFilter" should be called also for the initial
response.
So, my implementation of a "ContainerResponseFilter" that is provided
as an OSGi service and that works for other non-SSE endpoints should
be called to. And if this container response filter adds additional
headers, they should be present on the initial response.
Correct or not?

The chapter 9 (especially 9.3) does not contain any statement if the
SSE event sink is closed automatically if an exception is thrown.
So, to be on the safe side, the implementor is always responsible to
close the event think on all (also the error) branches.
Correct or not?

Best regards,
Markus

--
Mark Hoffmann
M.A. Dipl.-Betriebswirt (FH)
CEO/CTO

Phone:   +49 3641 384 910 0
Mobile:  +49 175 701 2201
E-Mail: m.hoffm...@data-in-motion.biz
Web: www.datainmotion.de

Data In Motion Consulting GmbH
Kahlaische Strasse 4
07745 Jena
Germany

Geschäftsführer/CEO
Mark Hoffmann
Jürgen Albert

Jena HRB 513025
Steuernummer 162/107/05779
USt-Id DE310002614

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

Reply via email to