服务总线的 AMQP 1.0 支持AMQP 1.0 support in Service Bus

Azure 服务总线云服务使用高级消息队列协议 (AMQP) 1.0 作为其主要通信方式。The Azure Service Bus cloud service uses the Advanced Message Queueing Protocol (AMQP) 1.0 as its primary means of communication. 在过去的十年中,Azure 与行业内的合作伙伴(相互竞争的消息传递代理的客户和供应商)开展合作,开发和发展 AMQP,并在 OASIS AMQP 技术委员会中开发了新的扩展。Azure has been engaged with partners across the industry, both customers and vendors of competing messaging brokers, to develop and evolve AMQP over the past decade, with new extensions being developed in the OASIS AMQP Technical Committee. AMQP 1.0 是 ISO 和 IEC 标准 (ISO 19464:20149)。AMQP 1.0 is an ISO and IEC standard (ISO 19464:20149).

通过 AMQP 可使用独立于供应商和实现的开放标准协议构建跨平台的混合应用程序。AMQP enables you to build cross-platform, hybrid applications using an vendor-neutral and implementation-neutral, open standard protocol. 可以借助使用不同语言和框架构建的且运行在不同操作系统上的组件来构建应用程序。You can construct applications using components that are built using different languages and frameworks, and that run on different operating systems. 所有这些组件均可连接到服务总线,并且能够高效且完全无损地无缝交换结构化业务消息。All these components can connect to Service Bus and seamlessly exchange structured business messages efficiently and at full fidelity.

简介:什么是 AMQP 1.0,为何它很重要?Introduction: What is AMQP 1.0 and why is it important?

通常,面向消息的中间件产品始终使用专用协议来支持客户端应用程序和代理之间的通信。Traditionally, message-oriented middleware products have used proprietary protocols for communication between client applications and brokers. 这意味着,在选择特定供应商的消息传递代理后,必须使用该供应商的库将客户端应用程序连接到该代理。This means that once you've selected a particular vendor's messaging broker, you must use that vendor's libraries to connect your client applications to that broker. 这会导致在一定程度上依赖于该供应商,因为将应用程序传送到其他产品需要对所有已连接应用程序进行代码改写。This results in a degree of dependence on that vendor, since porting an application to a different product requires code changes in all the connected applications. 在 Java 社区中,语言特定的 API 标准(如 Java 消息服务 (JMS))和 Spring Framework 的抽象在某种程度上缓和了这一痛点,但其功能范围非常窄,并且将使用其他语言的开发人员排除在外。In the Java community, language specific API standards like Java Message Service (JMS) and the Spring Framework's abstractions have alleviated that pain somewhat, but have a very narrow feature scope and exclude developers using other languages.

此外,连接来自不同供应商的消息传递代理比较棘手。Furthermore, connecting messaging brokers from different vendors is tricky. 这通常需要通过应用程序级桥接来将消息从一个系统移到另一个系统,并在其专用消息格式之间进行转换。This typically requires application-level bridging to move messages from one system to another and to translate between their proprietary message formats. 这是一个常见的要求;例如,在必须向较旧的独立系统提供新的统一接口时,或者在合并后集成 IT 系统时。This is a common requirement; for example, when you must provide a new unified interface to older disparate systems, or integrate IT systems following a merger. AMQP 允许与连接代理直接互连,例如使用 Apache Qpid Dispatch Router 之类的路由器或 RabbitMQ 之类的代理本机“铲子”。AMQP allows for interconnecting connecting brokers directly, for instance using routers like Apache Qpid Dispatch Router or broker-native "shovels" like the one of RabbitMQ.

软件产业是一个飞速发展的产业;新编程语言和应用程序框架的引入速度有时会非常惊人。The software industry is a fast-moving business; new programming languages and application frameworks are introduced at a sometimes bewildering pace. 同样,IT 系统的要求随着时间不断变化,并且开发人员希望利用最新的平台功能。Similarly, the requirements of IT systems evolve over time and developers want to take advantage of the latest platform features. 但有时候,所选消息传送供应商不支持这些平台。However, sometimes the selected messaging vendor does not support these platforms. 如果使用的是专用消息协议,其他供应商无法为这些新平台提供库。If messaging protocols are proprietary, it's not possible for others to provide libraries for these new platforms. 因此,必须使用构建网关等手段,或者可让你继续使用消息传递产品的网桥。Therefore, you must use approaches such as building gateways or bridges that enable you to continue to use the messaging product.

这些问题推动了高级消息队列协议 (AMQP) 1.0 的开发。The development of the Advanced Message Queuing Protocol (AMQP) 1.0 was motivated by these issues. 这种协议源于 JP Morgan Chase,像多数金融服务公司一样,该公司大量使用面向消息的中间件。It originated at JP Morgan Chase, who, like most financial services firms, are heavy users of message-oriented middleware. 目标非常简单:就是创建一个开放标准消息传送协议,从而能够借助使用不同语言、框架和操作系统构建的组件来构建基于消息的应用程序,而所有这些应用程序都使用各个供应商提供的同类最佳组件。The goal was simple: to create an open-standard messaging protocol that made it possible to build message-based applications using components built using different languages, frameworks, and operating systems, all using best-of-breed components from a range of suppliers.

AMQP 1.0 技术特性AMQP 1.0 technical features

AMQP 1.0 是一个高效、可靠的线级消息传递协议,可用于构建强大、跨平台的消息传递应用程序。AMQP 1.0 is an efficient, reliable, wire-level messaging protocol that you can use to build robust, cross-platform, messaging applications. 协议有一个简单的目标:定义用于在两方之间安全、可靠且高效传输消息的机制。The protocol has a simple goal: to define the mechanics of the secure, reliable, and efficient transfer of messages between two parties. 这些消息本身使用可移植数据表示进行编码,这种表示支持不同发送者和接收者完全无损地交换结构化业务消息。The messages themselves are encoded using a portable data representation that enables heterogeneous senders and receivers to exchange structured business messages at full fidelity. 下面简要介绍几个最重要的特性:The following is a summary of the most important features:

  • 高效:AMQP 1.0 是一个面向连接的协议,它将二进制编码用于协议指令以及通过该协议传输的业务消息。Efficient: AMQP 1.0 is a connection-oriented protocol that uses a binary encoding for the protocol instructions and the business messages transferred over it. 它融合了复杂的流控制方案,可最大限度地利用网络和已连接组件。It incorporates sophisticated flow-control schemes to maximize the utilization of the network and the connected components. 也就是说,该协议旨在实现有效性、灵活性和互操作性之间的平衡。That said, the protocol was designed to strike a balance between efficiency, flexibility and interoperability.
  • 可靠:使用 AMQP 1.0 协议交换消息时,可获得一系列可靠性保证,如即发即弃 (fire-and-forget) 和可靠的恰一次确认传送 (exactly-once acknowledged delivery)。Reliable: The AMQP 1.0 protocol allows messages to be exchanged with a range of reliability guarantees, from fire-and-forget to reliable, exactly-once acknowledged delivery.
  • 灵活:AMQP 1.0 是一个灵活的协议,可用于支持不同的拓扑。Flexible: AMQP 1.0 is a flexible protocol that can be used to support different topologies. 可以将同一协议用于客户端到客户端、客户端到代理以及代理到代理通信。The same protocol can be used for client-to-client, client-to-broker, and broker-to-broker communications.
  • 独立于代理模型:AMQP 1.0 规范对代理所使用的消息传送模型不作任何要求。Broker-model independent: The AMQP 1.0 specification does not make any requirements on the messaging model used by a broker. 这意味着可以向现有消息传送代理中轻松添加 AMQP 1.0 支持。This means that it's possible to easily add AMQP 1.0 support to existing messaging brokers.

AMQP 1.0 是一种标准(带有大写字母“S”)AMQP 1.0 is a Standard (with a capital 'S')

AMQP 1.0 是一种国际标准,已通过 ISO 和 IEC 的认证,认证编号为 ISO/IEC 19464:2014。AMQP 1.0 is an international standard, approved by ISO and IEC as ISO/IEC 19464:2014.

自 2008 年以来,AMQP 1.0 一直由一个由 20 多家公司(包括技术提供商和最终用户企业)组成的核心小组进行开发。AMQP 1.0 has been in development since 2008 by a core group of more than 20 companies, both technology suppliers and end-user firms. 在此期间,用户企业提供其实际业务需求,技术供应商则开发该协议来满足这些需求。During that time, user firms have contributed their real-world business requirements and the technology vendors have evolved the protocol to meet those requirements. 在整个过程中,供应商参加了研讨会,并在会上协作验证了其实现之间的互操作性。Throughout the process, vendors have participated in workshops in which they collaborated to validate the interoperability between their implementations.

2011 年 10 月,开发工作提交给结构化信息标准促进组织(Organization for the Advancement of Structured Information Standards,OASIS)内的技术委员会,随后 OASIS AMQP 1.0 标准于 2012 年 10 月发布。In October 2011, the development work transitioned to a technical committee within the Organization for the Advancement of Structured Information Standards (OASIS) and the OASIS AMQP 1.0 Standard was released in October 2012. 在开发该标准期间,以下公司参与了技术委员会的工作:The following firms participated in the technical committee during the development of the standard:

  • 技术供应商:Axway Software、Huawei Technologies、IIT Software、INETCO Systems、Kaazing、Microsoft、Mitre Corporation、Primeton Technologies、Progress Software、Red Hat、SITA、Software AG、Solace Systems、VMware、WSO2、Zenika。Technology vendors: Axway Software, Huawei Technologies, IIT Software, INETCO Systems, Kaazing, Microsoft, Mitre Corporation, Primeton Technologies, Progress Software, Red Hat, SITA, Software AG, Solace Systems, VMware, WSO2, Zenika.
  • 企业用户:Bank of America、Credit Suisse、Deutsche Boerse、Goldman Sachs、JPMorgan Chase。User firms: Bank of America, Credit Suisse, Deutsche Boerse, Goldman Sachs, JPMorgan Chase.

OASIS AMQP 技术委员会的现任主席代表 Red Hat 和 Microsoft。The current chairs of the OASIS AMQP Technical Committee represent Red Hat and Microsoft.

开放标准的公认好处包括:Some of the commonly cited benefits of open standards include:

  • 供应商锁定的几率较低Less chance of vendor lock-in
  • 互操作性Interoperability
  • 有大量库和工具可供使用Broad availability of libraries and tooling
  • 不会过时Protection against obsolescence
  • 随时可找到知识渊博的工作人员Availability of knowledgeable staff
  • 风险较低且可控Lower and manageable risk

AMQP 1.0 和 Service BusAMQP 1.0 and Service Bus

Azure 服务总线中对 AMQP 1.0 的支持意味着可以通过一系列使用有效的二进制协议的平台利用队列和发布/订阅中转消息传送功能。AMQP 1.0 support in Azure Service Bus means that you can leverage the Service Bus queuing and publish/subscribe brokered messaging features from a range of platforms using an efficient binary protocol. 此外,还可以生成由结合使用多个语言、框架和操作系统构建的组件组成的应用程序。Furthermore, you can build applications comprised of components built using a mix of languages, frameworks, and operating systems.

下图显示了一个部署示例,其中 Java 客户端运行在 Linux 上,并使用标准 Java 消息服务 (JMS) API 写入数据;而 .NET 客户端运行在 Windows 上,并通过服务总线使用 AMQP 1.0 交换消息。The following figure illustrates an example deployment in which Java clients running on Linux, written using the standard Java Message Service (JMS) API and .NET clients running on Windows, exchange messages via Service Bus using AMQP 1.0.

此图显示一个服务总线交换消息,其中包含两个 Linux 环境和两个 Windows 环境。

图 1:演示使用服务总线和 AMQP 1.0 进行跨平台消息传送的部署方案示例Figure 1: Example deployment scenario showing cross-platform messaging using Service Bus and AMQP 1.0

通过 Azure SDK 提供的所有受支持的服务总线客户端库均使用 AMQP 1.0。All supported Service Bus client libraries available via the Azure SDK use AMQP 1.0.

The AMQP-over-WebSockets protocol option runs over port TCP 443 just like the HTTP/REST API, but is otherwise functionally identical with plain AMQP. This option has somewhat higher initial connection latency because of extra handshake roundtrips and slightly more overhead as tradeoff for sharing the HTTPS port. If this mode is selected, TCP port 443 is sufficient for communication. The following options allow selecting the plain AMQP or AMQP WebSockets mode:

Language Option
.NET ServiceBusConnection.TransportType property with TransportType.Amqp or TransportType.AmqpWebSockets
Java com.microsoft.azure.servicebus.ClientSettings with com.microsoft.azure.servicebus.primitives.TransportType.AMQP or com.microsoft.azure.servicebus.primitives.TransportType.AMQP_WEB_SOCKETS
Node ServiceBusClientOptions has a webSocket constructor argument.
Python ServiceBusClient.transport_type with TransportType.Amqp or TransportType.AmqpOverWebSocket

此外,还可以使用任何 AMQP 1.0 兼容协议堆栈中的服务总线:In addition, you can use Service Bus from any AMQP 1.0 compliant protocol stack:

Language Library
Java Apache Qpid Proton-J
C/C++ Azure uAMQP C, Apache Qpid Proton-C
Python Azure uAMQP for Python, Apache Qpid Proton Python
PHP Azure uAMQP for PHP
Ruby Apache Qpid Proton Ruby
Go Azure Go AMQP, Apache Qpid Proton Go
C#/F#/VB AMQP .NET Lite, Apache NMS AMQP
JavaScript/Node Rhea

总结Summary

  • AMQP 1.0 是一个开放、可靠的消息传递协议,可用于构建跨平台的混合应用程序。AMQP 1.0 is an open, reliable messaging protocol that you can use to build cross-platform, hybrid applications. AMQP 1.0 是一种 OASIS 标准。AMQP 1.0 is an OASIS standard.

后续步骤Next steps

准备好了解详细信息?Ready to learn more? 请访问以下链接:Visit the following links:

[在 Azure Linux VM 上安装 Apache Qpid Proton-C]:[Installing Apache Qpid Proton-C on an Azure Linux VM]::