springamqp
We will look into Spring AMQP today.
今天我们将研究Spring AMQP。
Spring AMQP is the Spring implementation of AMQP-based messaging solutions. Spring AMQP provides us a “template” as a high-level abstraction for sending and receiving messages. We will look into following topics in this spring AMQP. tutorial.
Spring AMQP是基于AMQP的消息传递解决方案的Spring实现。 Spring AMQP为我们提供了一个“模板”,作为发送和接收消息的高级抽象。 我们将在今年Spring的AMQP中探讨以下主题。 教程。
We have already discussed some JMS concepts and examples in my previous posts. In this post, we are going to discuss AMQP protocol and Spring AMQP Messaging.
在之前的文章中,我们已经讨论了一些JMS概念和示例。 在本文中,我们将讨论AMQP协议和Spring AMQP Messaging。
AMQP stands for Advanced Message Queuing Protocol. AMQP is an open standard protocol for implementing MOMs (Message Oriented Middleware).
AMQP代表高级消息队列协议。 AMQP是用于实现MOM(面向消息的中间件)的开放标准协议。
We have JMS API to develop Enterprise Messaging systems but why we need another Messaging standard.
我们有JMS API来开发企业消息系统,但是为什么我们需要另一个消息标准。
The main drawback or limitation of JMS API is interoperability that means we can develop Messaging systems that will work only in Java-based applications. It does not support other languages.
JMS API的主要缺点或局限性是互操作性,这意味着我们可以开发仅在基于Java的应用程序中工作的消息系统。 它不支持其他语言。
AMQP solves the JMS API problem. The major advantage of AMQP is that it supports interoperability between heterogeneous platforms and messaging brokers. We can develop our Messaging systems in any language (Java, C++, C#, Ruby etc.) and in any operating system; still, they can communicate with each other by using AMQP based message brokers.
AMQP解决了JMS API问题。 AMQP的主要优点是它支持异构平台与消息传递代理之间的互操作性。 我们可以使用任何语言(Java,C ++,C#,Ruby等)和任何操作系统来开发消息系统。 他们仍然可以通过使用基于AMQP的消息代理相互通信。
In this section, we will discuss about what are the differences between JMS and AMQP protocols.
在本节中,我们将讨论JMS和AMQP协议之间的区别。
JMS Application works in any OS environment, but it supports only Java platform. If we want to develop the below system architecture by using JMS API then all those systems should be developed by using Java language only.
JMS应用程序可在任何OS环境中使用,但仅支持Java平台。 如果我们要使用JMS API开发以下系统架构,则所有这些系统都应仅使用Java语言开发。
But if we use AMQP standard to develop the same system, then we can develop those systems in any language that means System-1(JAVA), System-2(C#), System-3(Ruby) and System-4(C++).
但是,如果我们使用AMQP标准来开发相同的系统,则可以使用任何表示System-1(JAVA),System-2(C#),System-3(Ruby)和System-4(C ++)的语言来开发这些系统。 。
JMS API is specific for Java Platform only, but AMQP supports many technologies.
JMS API仅特定于Java平台,但是AMQP支持许多技术。
As we have already discussed, JMS API supports two kinds of messaging models: P2P(Peer-to-Peer) Model and PUB/SUB (Publisher/Subscriber) Model.
正如我们已经讨论的那样,JMS API支持两种消息传递模型:P2P(对等)模型和PUB / SUB(发布者/订阅者)模型。
AMQP supports five different Messaging models (or Exchange types)
AMQP支持五种不同的消息传递模型(或Exchange类型)
JMS Message is divided into 3 parts: Header, Properties, and Body.
AMQP Message is divided into 4 parts: Header, Properties, Body, and Footer.
JMS消息分为三个部分:标头,属性和正文。
AMQP消息分为4部分:标题,属性,正文和页脚。
JMS API supports 5 types of messages as part of the Body section, but AMQP supports only one type of message – Binary (bytes) message.
作为“正文”部分的一部分,JMS API支持5种消息,但是AMQP仅支持一种消息–二进制(字节)消息。
Spring Framework provides Spring AMQP API to integrate AMQP Message brokers with Spring applications to develop Enterprise Messaging Systems.
Spring框架提供了Spring AMQP API,以将AMQP消息代理与Spring应用程序集成以开发企业消息系统。
In AMQP Messaging systems, Message Publisher sends messages to Exchange. Publisher does not know which queue is configured to this Exchange and which Consumer is associated with this Queue.
在AMQP邮件系统中,Message Publisher将邮件发送到Exchange。 发布者不知道为此Exchange配置了哪个队列,以及与此队列关联的使用者。
While configuring Exchange, we will map it to one or more Queues by specifying some routing key.
在配置Exchange时,我们将通过指定一些路由键将其映射到一个或多个队列。
AMQP Consumer is connected to Queue and listening to messages with some routing key.
AMQP消费者已连接到队列并使用某些路由密钥侦听消息。
When Publisher sends a message into Exchange, then Exchange uses this routing key and send those messages to associated Queue. When the Queue receives messages, then associated Consumer receives those messages automatically.
当发布服务器向Exchange发送邮件时,Exchange将使用此路由密钥并将这些邮件发送到关联的队列。 当队列接收消息时,关联的使用者将自动接收这些消息。
For example, we have implemented our AMQP Messaging system by following above architecture.
例如,我们通过遵循上述架构实现了我们的AMQP消息系统。
If Publisher sends a message with Route key = 1, then this message is routed to Queue1, then to Consumer1.
如果发布者发送的路由键为1的消息,则此消息将路由到Queue1,然后路由到Consumer1。
If Publisher sends a message with Route key = 2, then this message is routed to Queue2, then to Consumer2.
如果发布者发送的路由键为2的消息,则此消息将路由到Queue2,然后路由到Consumer2。
NOTE: Most popular AMQP protocol implemented Message brokers or JMS Servers are:
注意:最受欢迎的AMQP协议实现的消息代理或JMS服务器是:
Spring Framework provides two set of APIs to deal with AMQP protocol servers. Spring AMQP Projects are located at the following website:
Spring Framework提供了两组API来处理AMQP协议服务器。 SpringAMQP项目位于以下网站:
https://spring.io/projects/spring-amqp
https://spring.io/projects/spring-amqp
Spring RabbitMQ AMQP API is used to implement messaging applications with Spring Rabbit MQ server. This API is developed in two Spring modules:
Spring RabbitMQ AMQP API用于通过Spring Rabbit MQ服务器实现消息传递应用程序。 此API在两个Spring模块中开发:
It is base abstraction for AMQP Protocol implementation.
它是AMQP协议实现的基础抽象。
It is the RabbitMQ implementation.
它是RabbitMQ的实现。
This API is used to implement messaging applications with Apache Active MQ server. This API uses Spring AMQP abstraction module with ActiveMQ API:
该API用于通过Apache Active MQ服务器实现消息传递应用程序。 该API将Spring AMQP抽象模块与ActiveMQ API结合使用:
It is base abstraction for AMQP Protocol implementation.
它是AMQP协议实现的基础抽象。
It is the ActiveMQ implementation.
这是ActiveMQ实现。
NOTE:
注意:
activemq-spring
(It’s not from Pivotal Team). ActiveMQ Server来自Apache Software Foundation。 Apache ActiveMQ已经发布了一个支持Spring Framework的API,该API是activemq-spring
(不是来自Pivotal Team)。 That’s it all about Spring AMQP Messaging.
Spring AMQP Messaging就是这样。
Further Reading: Spring RabbitMQ, Apache ActiveMQ
扩展阅读: Spring RabbitMQ , Apache ActiveMQ
springamqp