who calls subscribe on Flux or Mono in reactive webapplication

前端 未结 2 525
死守一世寂寞
死守一世寂寞 2020-12-20 17:02

I am looking at some examples of reactive web applications and i am seeing them like this

@RequestMapping(value = \"/{id}\", method = RequestMethod.GET)
@Res         


        
2条回答
  •  粉色の甜心
    2020-12-20 17:57

    It depends on which server you use.

    For instance, Tomcat, Jetty (Servlet 3.1 non-blocking I/O) - ServletHttpHandlerAdapter from org.springframework.http.server.reactive package.

    Subscription happens in service method:

    @Override
    public void service(ServletRequest request, ServletResponse response) throws 
      ServletException, IOException {        
        ...
        HandlerResultSubscriber subscriber = new HandlerResultSubscriber(asyncContext, 
            isCompleted, httpRequest);
        this.httpHandler.handle(httpRequest, httpResponse).subscribe(subscriber);
    }
    

提交回复
热议问题