# 中间件

**中间件**是位于应用程序与操作系统或网络之间的软件，使分布式系统的各部分能够通信并管理数据；MDN 将其宽泛地定义为任何能使系统各部分通信并管理数据的软件或服务<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/Middleware)</sup>。这一类别最初是作为操作系统之上的附加层出现的，用以简化复杂的应用开发，随后进入数据集成领域，继而成为网络应用的促进者，最终成为分布式环境、应用、系统和平台的一般组成部分<sup>[2](https://onlinelibrary.wiley.com/doi/full/10.1002/cpe.2817)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 使系统各部分能够通信并管理数据的软件或服务<sup>[1](https://developer.mozilla.org/en-US/docs/Glossary/Middleware)</sup> |
| 术语历史 | 20世纪80年代末首次出现，指网络连接管理软件；90年代中期开始广泛使用<sup>[3](https://eecs.wsu.edu/~bakken/middleware_files/middleware.htm)</sup> |
| 里程碑标准 | CORBA 1.0，1991年10月采纳，定义了对象模型、IDL 和调用 API<sup>[4](https://www.omg.org/corba/history_of_corba.htm)</sup> |
| 互操作性里程碑 | CORBA 2.0（1996年8月）增加了 GIOP/IIOP 互操作架构，使不同厂商的 ORB 能够通信<sup>[4](https://www.omg.org/corba/history_of_corba.htm)</sup> |
| 主要类型 | 面向消息、RPC、数据库、API、对象请求代理、事务、流式、设备、门户、机器人以及企业应用集成中间件<sup>[5](https://www.ibm.com/think/topics/middleware)</sup> |
| Web 框架形态 | 在 ASP.NET Core 中，中间件组件构成请求管道，其顺序在 `Program.cs` 中设定，对安全性、性能和功能至关重要<sup>[6](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware?tabs=aspnetcore2x)</sup> |
| 当前平台 | IBM MQ、Apache Kafka、Apache ActiveMQ、RabbitMQ 和 TIBCO 是大型企业运行的中间件环境<sup>[7](https://www.techradar.com/pro/the-foundation-agentic-ai-cant-function-without)</sup> |

## 历史

中间件最初是20世纪80年代末用来指称管理网络连接的软件的一个标签；直到90年代中期才获得广泛采用，彼时网络技术已经足够普及且为人熟知。<sup>[3](https://eecs.wsu.edu/~bakken/middleware_files/middleware.htm)</sup> 对那个时期的一种描述将中间件比作“客户端/服务器”中间的那个斜杠，即连接两端的层次<sup>[2](https://onlinelibrary.wiley.com/doi/full/10.1002/cpe.2817)</sup>。Cronus 是第一个主要的分布式对象中间件系统，Clouds 和 Eden 是同时代的产品<sup>[3](https://eecs.wsu.edu/~bakken/middleware_files/middleware.htm)</sup>。

[数据集成](https://www.edgepedia.org/zh/data-integration)中间件如 CORBA 于1991年登场，为应用集成和数据接口问题提供了解决方案<sup>[2](https://onlinelibrary.wiley.com/doi/full/10.1002/cpe.2817)</sup>。

## CORBA 与分布式对象中间件

[对象管理组织](https://www.edgepedia.org/zh/object-management-group)成立于1989年，致力于制定标准，使分布式软件组件能够互操作，而无需处处依赖某一厂商的运行时<sup>[8](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)</sup>。CORBA——[公共对象请求代理体系结构](https://www.edgepedia.org/zh/common-object-request-broker-architecture)——成为最著名的成果：它定义了对象模型、接口语言、代理架构以及调用分布式对象操作的互操作规则<sup>[8](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)</sup>。

CORBA 1.0 于1991年10月采纳，包含 CORBA 对象模型、接口定义语言（IDL）、动态调用 API 和接口仓库，并提供了 C 语言的单一语言映射<sup>[4](https://www.omg.org/corba/history_of_corba.htm)</sup>。IDL 以语言中立的方式规定可调用的操作和数据类型，使工具能够将其翻译为 C、C++、Java 及其他语言；对象请求代理（ORB）位于调用方与对象实现之间<sup>[8](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)</sup>。

CORBA 2.0（1996年8月）是第一次重大修订。它增加了动态骨架接口、用于客户端可移植性的初始引用解析器，以及 GIOP、IIOP 和 DCE CIOP 的“开箱即用”互操作架构，使不同厂商的两个符合规范的 ORB 能够通过标准化的面向互联网协议通信，而不再仅限于某一厂商的专有网络栈内<sup>[4](https://www.omg.org/corba/history_of_corba.htm)</sup><sup> • </sup><sup>[8](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)</sup>。后续版本增加了 DCOM 互操作、POA 服务器可移植性增强以及 IDL 到 Java 的映射<sup>[4](https://www.omg.org/corba/history_of_corba.htm)</sup>。

随着时间推移，该生态系统增加了命名、事务、安全、事件通道、实时规约、组件模型以及更多语言映射。这种广度满足了企业需求，但也增加了平台的概念和操作负担——这是标准制定中反复出现的动态：互操作压力促使规范覆盖更多边缘情况<sup>[8](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)</sup>。OMG 的规范历史已达3.4版，于2021年采纳<sup>[8](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)</sup>。

## 中间件的类型

IBM 将最知名和最常用的类型编目为：面向消息的中间件（MOM）、远程过程调用（RPC）中间件、数据或数据库中间件、API 中间件、对象请求代理中间件、事务中间件、异步数据流中间件、设备中间件、门户中间件、机器人中间件和企业应用集成中间件<sup>[5](https://www.ibm.com/think/topics/middleware)</sup>。

**面向消息的中间件。** MOM 使使用不同消息传递协议的应用组件能够通信和交换消息；除了翻译或转换消息之外，它还管理路由，使消息以适当的顺序到达正确的组件<sup>[5](https://www.ibm.com/think/topics/middleware)</sup>。MOM 是一组服务，在 TCP/IP 和 SNA 等网络层之上提供传输层<sup>[9](https://www.redbooks.ibm.com/redbooks/pdfs/sg246336.pdf)</sup>，而消息代理是 MOM 解决方案中的软件模块，为开发者提供处理应用组件之间数据流的标准化手段<sup>[10](https://www.ibm.com/think/topics/message-brokers)</sup>。

**RPC 与消息传递。** RPC 中间件作用于对象或函数接口，提供高内聚性但也带来高耦合性，而 MOM 典型的发布/订阅模型则以较低的内聚性为代价换取低耦合性和高可扩展性；人们提出了混合设计来抵消各自的缺点<sup>[11](https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART002035195)</sup>。对企业平台的性能研究比较了 J2EE 服务器上的 HTTPServlets、RMI 和基于 JAX-RPC 的 Web 服务等具体技术栈，以揭示每种技术对分布式应用响应时间的影响<sup>[12](https://www.sciencedirect.com/science/article/abs/pii/S0164121206002731)</sup>。

## Web 框架中的中间件

这个词在 Web 应用框架中有第二种更狭窄的含义。在 [ASP.NET Core](https://www.edgepedia.org/zh/asp-net-core) 中，请求管道是一系列依次调用的请求委托；每个中间件组件可以在下一个委托之前和之后执行工作，并且可以通过不调用下一个组件来短路管道<sup>[6](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware?tabs=aspnetcore2x)</sup>。组件在 `Program.cs` 中添加的顺序决定了它们在请求上的调用顺序以及在响应上的反向顺序，而这个顺序对安全性、性能和功能至关重要；例如，CORS 中间件必须出现在响应缓存中间件之前，异常处理委托必须尽早调用，以便捕获后续阶段抛出的异常<sup>[6](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware?tabs=aspnetcore2x)</sup>。每个组件有两次行动机会：在请求进入时进行预处理，在终止中间件产生输出后于返回途中进行后处理<sup>[13](https://learn.microsoft.com/en-us/archive/msdn-magazine/2019/june/cutting-edge-revisiting-the-asp-net-core-pipeline)</sup>。

## 当前实践

开源企业消息传递和事件流平台，如 [Apache Kafka](https://www.edgepedia.org/zh/apache-kafka) 和 ActiveMQ，改变了银行、制造商、零售商及其他严重依赖中间件的企业构建和运行数字系统的方式：实时移动数据、运行事件驱动应用以及采用模块化架构变得更加简单，无论系统部署在本地还是云端。<sup>[14](https://www.techradar.com/pro/why-governance-is-moving-to-the-middleware-layer)</sup> 随着集成环境扩展到代理、流、队列、API、文件交换和合作伙伴集成，治理正在向中间件和集成层转移，因为支付事件、库存更新、客户记录和合规敏感交易都经过这一层，而所有权分散在开发、基础设施、运维、安全和合规团队之间<sup>[14](https://www.techradar.com/pro/why-governance-is-moving-to-the-middleware-layer)</sup>。

中间件遥测本身已成为一个规模问题。大型企业在包括 IBM MQ、Apache Kafka、Apache ActiveMQ、RabbitMQ 和 TIBCO 在内的环境中运行事务，每一步都可能引入故障点，导致数据积压或停滞；中间件遥测的数据量往往过于密集，操作人员无法手工评估，因此正在应用分析工具，使 AI 系统能够在应用、消息流和事务路径的上下文中解释事件<sup>[7](https://www.techradar.com/pro/the-foundation-agentic-ai-cant-function-without)</sup>。

中间件在专业领域也仍然是一个活跃的研究方向。在医疗保健领域，人们提出了中间件解决方案来管理医疗物联网环境的异构性、可扩展性和集成需求，尽管许多提出的系统是为特定应用而设计的，不经核心修改无法适应其他应用<sup>[15](https://pmc.ncbi.nlm.nih.gov/articles/PMC7313277/)</sup>。在汽车和机器人领域，比较研究衡量中间件平台在端到端延迟、吞吐量、发现时间以及跨网络拓扑扩展方面的表现<sup>[16](https://arxiv.org/abs/2505.02734)</sup>。

## References

1. [Middleware, MDN Web Docs Glossary](https://developer.mozilla.org/en-US/docs/Glossary/Middleware)
2. [Middleware is STILL Everywhere!!!, Al-Jaroodi et al., Concurrency and Computation: Practice and Experience (2012)](https://onlinelibrary.wiley.com/doi/full/10.1002/cpe.2817)
3. [History of Middleware, D. E. Bakken, Washington State University](https://eecs.wsu.edu/~bakken/middleware_files/middleware.htm)
4. [CORBA History, Object Management Group](https://www.omg.org/corba/history_of_corba.htm)
5. [What Is Middleware?, IBM](https://www.ibm.com/think/topics/middleware)
6. [ASP.NET Core middleware, Microsoft Learn](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware?tabs=aspnetcore2x)
7. [The foundation agentic AI can't function without, TechRadar Pro (2026)](https://www.techradar.com/pro/the-foundation-agentic-ai-cant-function-without)
8. [CORBA and the Dream of Language-Neutral Distributed Objects, CodeHistory](https://www.codehistory.org/distributed-systems-cloud-computing/corba-dream-language-neutral-distributed-objects/)
9. [Messaging Solutions in a Linux Environment, IBM Redbooks](https://www.redbooks.ibm.com/redbooks/pdfs/sg246336.pdf)
10. [What Is a Message Broker?, IBM](https://www.ibm.com/think/topics/message-brokers)
11. [Design and Implementation of Publish/Subscribe Model Based RPC Middleware, Journal of IKEEE (2015)](https://www.kci.go.kr/kciportal/ci/sereArticleSearch/ciSereArtiView.kci?sereArticleSearchBean.artiId=ART002035195)
12. [An evaluation of the middleware's impact on the performance of object oriented distributed systems, Journal of Systems and Software (2007)](https://www.sciencedirect.com/science/article/abs/pii/S0164121206002731)
13. [Revisiting the ASP.NET Core Pipeline, MSDN Magazine (June 2019)](https://learn.microsoft.com/en-us/archive/msdn-magazine/2019/june/cutting-edge-revisiting-the-asp-net-core-pipeline)
14. [Why governance is moving to the middleware layer, TechRadar Pro (2026)](https://www.techradar.com/pro/why-governance-is-moving-to-the-middleware-layer)
15. [Study of Middleware for Internet of Healthcare Things and Their Applications, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC7313277/)
16. [Automotive Middleware Performance: Comparison of FastDDS, Zenoh and vSomeIP, arXiv](https://arxiv.org/abs/2505.02734)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/middleware

English original: https://www.edgepedia.org/middleware
