Spring Boot 2 &Spring 5 容器混淆 [英] Spring Boot 2 & Spring 5 Container confusion

查看:55
本文介绍了Spring Boot 2 &Spring 5 容器混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Spring Boot 1.4.3 项目.最近我提出了一个要求,我必须将日志从服务器发送到我的 Web 应用程序并在网页上打印日志.我知道 WebSockets,但我一直在寻找更好的解决方案,我遇到了响应式编程和 gRPC.

I have a Spring boot 1.4.3 project. Recently I have come up with a requirement where I have to send logs from server to my web application and print the logs on the web page. I am aware of WebSockets but I was looking for better solutions and I came across, Reactive Programming and gRPC.

Spring 在 Spring 版本 5 中支持响应式编程,但我在 gRPC 和响应式编程之间很困惑.gRPC 具有双向流,它构建在 Netty 之上,并提供与将数据从服务器推送到客户端(如响应式编程)相同的功能.那么我应该使用哪一个,如果你能消除我的困惑,那就太好了.

Spring is supporting Reactive Programming in Spring version 5, but I am quite confused between gRPC and Reactive Programming. gRPC features Bi-Directional streaming which is built on top of Netty and provides the same facility as pushing data from the server to clients like Reactive Programming. So which one should I use, If you can clear me on this confusion it would be really great.

此外,如果我转向支持 Spring 版本 5 的 Spring Boot 2,该项目将在 Netty 上运行.我的困惑是,我是否必须在不同的容器上运行我的应用程序,例如 Jetty 服务器上的普通 REST 端点和 netty 服务器上的 Reactive API 或 Spring 将通过处理 netty 上的反应性请求和其余的通用 REST 来为我开箱即用地处理这个问题jetty 服务器上的 API,因为据我所知 Netty 不是 Servlet Container.

Also, If I move to Spring Boot 2 which supports Spring Version 5, the project will be running on Netty. My confusion is, do I have to run my application on different containers like for normal REST endpoints on Jetty server and for Reactive API on netty server or Spring will handle this for me out of the box by handling reactive requests on netty and remaining general REST API on the jetty server, because as far as I know Netty is not a Servlet Container.

推荐答案

反应式编程的一个关键特性是背压,以及以非阻塞方式实现的背压.在撰写本文时,gRPC 不支持此.

One key feature of reactive programming is back pressure, and back pressure that's implemented in a non-blocking manner. At the time of writing, gRPC doesn't support this.

除了客户端和服务器之间的通信之外,响应式编程还有更多内容.要真正具有反应性,您需要从头到尾都是反应性的.这包括对您的数据存储的反应式访问等.据我所知,这不是 gRPC 能够解决的问题.

There's also much more to reactive programming than the communication between a client and a server. To be truly reactive, you need to be reactive from end to end. This includes reactive access to your data store, etc. As far as I know, this isn't something that's tackled by gRPC.

您不应尝试将传统的基于 Servlet 的 Web 框架(例如 Spring MVC)与 WebFlux(Spring 的反应式 Web 框架)混合使用.您应该编写 100% 响应式 Web 应用程序或 100% 基于 Servlet 的 Web 应用程序.

You shouldn't try to mix the use of a traditional Servlet-based web framework (such as Spring MVC) with use of WebFlux (Spring's reactive web framework). You should either write a 100% reactive web application or a 100% Servlet-based web application.

这篇关于Spring Boot 2 &Spring 5 容器混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆