当前位置:网站首页>AMQP protocol

AMQP protocol

2022-06-23 17:26:00 User 7353950

The opening

When it comes to message queuing , I believe you are not new . In fact, everyone has used it in their daily work . It is believed that most of the R & D is just staying in the process of using message queues , The knowledge points inside are not very systematic , Some powerful functions may not be accessible due to the business form or business level of the company . That's what old cats do at work , What is used MQ All are encapsulated by architects , Simply call . In order to better understand why , So the old cat took the time to sort it out MQ A series of knowledge points , It is said that “ Bad writing is better than good memory ”, So the old cat recorded it in the process of learning . Share it with friends in need , Of course, it is also convenient for you to consult later , So there is this series of articles .

AMQP Protocol Brief

Many of you have come into contact with RabbitMq, Actually RabbitMq Namely AMQP An implementation of the protocol .

Rather than AMQP It's a protocol , In fact, it is a standard . Is an open standard for application layer protocols , Designed for message-oriented middleware .AMQP It's a network protocol that delivers asynchronous messages between processes . Its full name is AMQP(Advanced Message Queuing Protocol). The client and message middleware based on this protocol can deliver messages , Not by the client / Different middleware products , Restrictions on different development languages and other conditions .AMQP The main feature is message oriented 、 queue 、 route ( Including point-to-point and release / subscribe )、 reliability 、 Security .AMQP The behavior of the message provider and the client is mandatory , This enables different vendors to truly realize interoperability .

About Kafka and AMQP Add a separate point

I believe that in our daily work, in addition to RabbitMQ Besides, many friends have used it kafka Well , that kafka and AMQP What does it matter ?

The answer is : No problem .

Kafka Not a message queue at all . Officially ,Kafka It's a streaming platform (stream processing platform).Kafka It was designed to support high throughput log processing , It just happens to be able to implement most of the functions of message queuing .Kafka Used “ Black science and technology ”( For example, zero copy / Memory mapping , And right page cache The use of , Of course, these follow-up sharing kafka And then synchronize with the little buddy when you get there ) They are out of the scope of the standard message queue design , So we can't simply think of Kafka Than RabbitMQ Etc AMQP Better message queuing for . for example ,RabbitMQ Support dead letter queue 、 Delay queue 、 Priority queue 、 multi-tenancy 、 Push mode consumption, etc ,Kafka They don't support .

AMQP and JMS The difference between

Speaking of AMQP agreement , You have to talk JMS.JMS It is an attempt to standardize the early message oriented middleware , It's just API Level has been standardized . Only applicable to Java The message oriented middleware specification of the platform , Support Java Message exchange between applications . And by providing standard production 、 send out 、 The interface to receive messages simplifies the development of enterprise applications . If you want to know more about JMS In fact, Baidu Encyclopedia has a very detailed explanation . The specific links :https://baike.baidu.com/item/JMS/2836691?fr=aladdin, In addition, if a small partner wants its specific interface document , You can download here :https://download.oracle.com/otndocs/jcp/7195-jms-1.1-fr-spec-oth-JSpec/

JMS A brief summary

JMS It mainly includes two models ,(1) Point to point model (2) Publish and subscribe model

Point to point : The producer sends a message to the queue. Only one listener can get the message .

Publish subscribe : The producer delivers a message to the queue , All subscribers listening to the queue can get the message .

JMS Five different message body formats

JMS Five different message body formats are defined , And the type of message called , Allows you to send and receive data in different forms , Provides some level of compatibility with existing message formats .

  • StreamMessage – Java Data flow of original value
  • MapMessage– A set of names - It's worth it
  • TextMessage– A string object
  • ObjectMessage– A serialized Java object
  • BytesMessage– One byte data flow

AMQP Model generalization

AMQP Model as follows

  • Server: also called Broker, Accept client connections , Realization AMQP Physical services .
  • Connection: Connect , Application and Broker The Internet connection .
  • Channel: Network channel . Almost all operations are in Channel In the middle of ,Channel It's a channel for reading and writing messages . The client can create multiple Channel, Every Channel Represents a conversational task .
  • Message: news , Data transferred between the server and the application , from Properties and body form ,Properties You can decorate the message , For example, the priority of a message 、 Advanced features like delay ;Body Is the message body .
  • Virtual host: Virtual address , Due to logical isolation , Top level message routing . One Virtual Host There can be several Exchange and Queue, The same Virtual Host It can't have the same name Exchange or Queue.
  • Exchange: Switch , receive messages , Forward the message to the bound queue according to the routing key .
  • Binding:Exchange and Queue Virtual connection between ,binding Can contain routing Key.
  • Routing Key: A routing rule , Virtual machines can use it to determine how to route a particular message .
  • Queue: Also known as Message Queue, Message queue , Save messages and forward them to consumers .

AMQP and JMS contrast

The above has made some simple generalizations , If you feel that you are lacking , Not too complete , Then you can consult relevant information by yourself .

Contrast direction

JMS

AMQP

Definition

Java API

agreement

Cross language

no

yes

Cross platform

no

yes

Contrast the model

①Peer-2-Peer( Point to point );②Pub/sub( Publish subscribe )

①direct exchange;②fanout exchange;③topic change;④headers exchange;⑤system exchange. In essence , The last four and JMS Of pub/sub The model doesn't make much difference , Only in the routing mechanism to do a more detailed division ;( This follow-up old cat will share with you rabbitMq I'll talk about it in detail )

Message type

Support multiple message types , We mentioned above

byte[]( Binary system )

原网站

版权声明
本文为[User 7353950]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231642463845.html