springamqp_SpringAMQP

springamqp

We will look into Spring AMQP today.

今天我们将研究Spring AMQP。

SpringAMQP (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中探讨以下主题。 教程。

  1. What is AMQP?

    什么是AMQP?
  2. Why we need AMQP?

    为什么我们需要AMQP?
  3. Difference between JMS and AMQP

    JMS和AMQP之间的区别
  4. How Spring AMQP works?

    Spring AMQP如何工作?
  5. Spring AMQP Modules

    Spring AMQP模块

什么是AMQP? (What is 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(面向消息的中间件)的开放标准协议。

为什么我们需要AMQP? (Why we need AMQP?)

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的消息代理相互通信。

JMS和AMQP之间的区别 (Difference between JMS and AMQP)

In this section, we will discuss about what are the differences between JMS and AMQP protocols.

在本节中,我们将讨论JMS和AMQP协议之间的区别。

  1. Interoperability

    互通性
  2. 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支持许多技术。

  3. Messaging Models

    讯息模型
  4. 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类型)

    1. Direct Exchange

      直接交换
    2. Fanout Exchange

      扇出交换
    3. Topic Exchange

      主题交流
    4. Headers Exchange

      标头交换
    5. System Exchange

      系统交换
  5. Message Structure

    讯息结构
  6. 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部分:标题,属性,正文和页脚。

  7. Message Types

    讯息类型
  8. 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 AMQP如何工作? (How Spring AMQP works?)

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服务器是:

  1. Apache Active MQ server

    Apache Active MQ服务器
  2. Spring Rabbit MQ server

    Spring Rabbit MQ服务器

Spring AMQP模块 (Spring AMQP Modules)

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

  1. Spring RabbitMQ AMQP API

    Spring RabbitMQ AMQP API
  2. 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模块中开发:

  • spring-amqp:

    spring-amqp:
  • It is base abstraction for AMQP Protocol implementation.

    它是AMQP协议实现的基础抽象。

  • spring-rabbit:

    Spring兔子:
  • It is the RabbitMQ implementation.

    它是RabbitMQ的实现。

  • Spring ActiveMQ AMQP API

    Spring ActiveMQ AMQP API
  • 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结合使用:

    • spring-amqp:

      spring-amqp:
    • It is base abstraction for AMQP Protocol implementation.

      它是AMQP协议实现的基础抽象。

    • activemq-spring:

      activemq-spring:
    • It is the ActiveMQ implementation.

      这是ActiveMQ实现。

    NOTE:

    注意:

    • Both Spring AMQP and Spring RabbitMQ Modules are from Pivotal Team (Spring Framework). RabbitMQ servers is also from Pivotal Team.

      Spring AMQP和Spring RabbitMQ模块均来自Pivotal团队(Spring框架)。 RabbitMQ服务器也来自Pivotal Team。
    • ActiveMQ Server is from Apache Software Foundation. Apache ActiveMQ has released an API to support Spring Framework that is 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 RabbitMQApache ActiveMQ

    翻译自: https://www.journaldev.com/11643/spring-amqp

    springamqp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值