https://blog.itkonekt.com/2018/06/27/server-sent-events-in-spring/

 


https://supawer0728.github.io/2018/03/15/spring-http-stereamings/

 

 

http://kwseo.github.io/2017/03/25/sse/

 

https://dzone.com/articles/spring-boot-server-sent-events-tutorial

 

https://golb.hplar.ch/2017/03/Server-Sent-Events-with-Spring.html

 

https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/sse-emitter.html

 

http://andang72.blogspot.com/2018/05/server-sent-events.html

 

 

- 스프링 컨트롤러에서 SSE 사용하기

스프링은 SseEmitter 불리우는 클래스를 사용하여 HTTP 응답을 text/event-stream 타입으로 리턴한다.

이를 위해서 아래와 같이 web.xml 파일에 sync-support 를 반드시 추가해주어야 한다.

(servelt dispatcher와 filter 모두 추가해줘야 함)

 

<!-- spring dispatcher 설정 (java configuration) -->
<servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextClass</param-name>
        <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
    </init-param>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>com.sample.configuration.web.WebDispatcherServlet</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
</servlet>

<servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

 

<!-- spring session filter -->
<filter>
    <filter-name>springSessionRepositoryFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <async-supported>true</async-supported>
</filter>
<filter-mapping>
    <filter-name>springSessionRepositoryFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>

 

Posted by 張's blog
,