What is the DuBBo protocol?

The fundamental question is, what is the DuBBo protocol?

How consumers and providers actually communicate — essentially, how they identify each other’s data.

It mainly includes several aspects

1. When does it end when one party reads binary data of the other party?

2. Serialization method?

That is, object and binary conversion.

The Dubbo framework defaults to the Dubbo protocol

But it can also be HTTP

That is, the Dubbo service supports consumer HTTP requests. So, here are a few scenarios:

1. Generally duBBO protocol

2. It can also be HTTP

Occupy a new separate port, also visible in the Dubbo console.

3. The same service can support both DUBBO and HTTP

The service is visible on both the Dubbo protocol port and HTTP protocol port of the Dubbo console.


What are the application scenarios of HTTP? Why use HTTP when you use dubbo?

For example, in the company, some old system, no Dubbo function, only HTTP function, but also want to call your service, how to do?

Only HTTP is supported.


Why use dubbo protocol?

Because HTTP and Dubbo are the reverse of each other, HTTP was changed to Dubbo to speed things up.

The default serialization is hessian2

Each protocol has its own way of serializing.

Serialization refers to how objects and binaries are converted.

For example, Java has its own serialization approach, specifically based on the Serializable interface and ObjectOutputStream class.

The serialization of dubbo is hessian2.

The communication framework is NetTY

Asynchronous nio

Why asynchronous? Speed up.

Why do the nio? Netty is based on NIO, but still speeds up.

Single long connection

Number of connections: single connection.

Connection mode: Long connection.

Why single connection? Multiplexing connections.

Why long connections? Again, multiplexing connections.

Netty NIO stands for multiplexed connection.

Full configuration item

<dubbo:protocol name= "dubbo" Port = "9090" server= "netty" Client = "netty" codec= "dubbo" // Serialization = "hessian2" // Serialized charset= "UTF-8" ThreadPool = "fixed" threads= "100" queues= "0" IOThreads = "9" buffer= "8192" Accepts = "1000" Content = "8388608" / >Copy the code

Realize the principle of

Communication protocols, in essence, allow consumers and providers to identify each other’s content.

Specifically, object and binary conversion.

Communication process,

1. Consumer to provider

The object is converted to binary.

2. The provider converts the binary to an object

The first step is when one party is reading the other party’s data, they need to know when to stop?

There are several ways,

1. Fixed length

Cons: inflexible. Because the length of the content is not fixed.

2. Special terminator

Disadvantages: Content cannot contain special terminators.

3. Non-fixed length

Two parts:

1) Content length

The part that stores the length of the content is fixed length.

2) The content itself

Non-fixed length, mainly refers to the length of the content itself is not fixed.


The Dubbo protocol is of unfixed length

details

instructions

The second step is, after you’re done, how do you convert binary data into objects?

Binary to object, which serialization is used.

reference

Dubbo.apache.org/zh/docs/ref…

Dubbo.apache.org/zh/blog/201…

Dubbo.apache.org/zh/docs/con…