挣扎于中间件的概念 - 中间件是一个独立的进程还是应用程序的一部分?

Struggling with the concept of middelware - Is a middleware an independent process or part of an application?

我很难理解中间件的概念。 运行 时的中间件是否是 运行 独立于应用程序并且必须通过套接字调用(或使进程与另一个进程通信的任何其他方式)的东西?

或者它是应用程序的一部分,只是一个处理某些任务的层。

例如: 在 Java 中,我有一个请求数字“getNumber()”的函数。这个函数应该转化为一个http请求。中间件的工作是获取函数名称并使用某种协议将其转换为 http 请求,然后 return 它。

中间件会是我的 java 包中的 class,我只是通过引用直接调用,如“middleware.getNumber()”,还是 运行 作为我通过套接字通信或类似方式调用的独立进程。

中间件将是结束调用 getNumber() 函数的 HTTP 堆栈。从客户端的角度来看,它是一个单独的进程,从 getNumber 的角度来看 - 它和 HTTP 堆栈将在同一个进程中。

更多详情:

中间件的目的是弥合应用程序之间的差距,实现通信和input/output(来自:https://en.wikipedia.org/wiki/Middleware)。在您的情况下,应用程序的业务逻辑是 return 数字 (getNumber()),因此中间件将负责输出转换。同样来自同一篇维基文章:

In this more specific sense middleware can be described as the dash ("-") in client-server, or the -to- in peer-to-peer. Middleware includes web servers, application servers, content management systems, and similar tools that support application development and delivery.[4]

勾选https://en.wikipedia.org/wiki/Middleware_(distributed_applications):

The distinction between operating system and middleware functionality is, to some extent, arbitrary. While core kernel functionality can only be provided by the operating system itself, some functionality previously provided by separately sold middleware is now integrated in operating systems. A typical example is the TCP/IP stack for telecommunications, nowadays included virtually in every operating system.