ActiveMQ transmission protocol
Network protocols supported by ActiveMQ
Different configuration, MQ performance is different
Visit the official website: https://activemq.apache.org/connectivity
(1)Transmission Control Protocol(TCP)-- 默认
1. This is the default Broker configuration. The TCP Client listens on port 616162. Before data is transmitted over the network, the data must be serialized. The message is serialized into a byte stream through a wire protocol.
2. By default, ActiveMQ calls the wire protocol OpenWire, and its purpose is to promote efficiency and rapid data interaction on the network.
3. The URI form of TCP connection is such as: tcp://hostname:port? key=value&key=value, the following parameters are optional
4. Advantages of TCP transmission:
(4.1) TCP protocol transmission has high reliability and strong stability(4.2) High efficiency: byte stream transmission, high efficiency
(4.3) Effectiveness and usability: wide application, support any platform5. For the configurable parameters of the Transport protocol, please refer to the official website: http://activemq.apache.org/configuring-version-5-transports.html
2)New I/O API Protocol(NIO)
The client-broker communication protocols supported by ActiveMQ are: TCP, NIO, UDP, SSL, Http(s), VM.
The file for configuring the Transport Connector is in the <transportConnectors> tag in the conf/activemq.xml of the activeMQ installation directory.
1. The NIO protocol is similar to the TCP protocol, but NIO focuses more on the underlying access operations. It allows developers to have more client calls and server-side calls to the same resource.
Heavy load
2. Scenarios suitable for using NIO protocol:
(2.1) There may be a large number of Clients to connect to the Broker. In general, a large number of Clients to connect to the Broker is restricted by the threads of the operating system. Therefore, the implementation of NIO requires fewer threads to run than TCP, so it is recommended to use the NIO protocol
(2.2) There may be a very slow network transmission for Broker, NIO provides better performance than TCP.
3. The URI form of NIO connection: nio/hostname:port?key = value
4. Transport Connector configuration example, refer to the official website:
http://activemq.apache.org/configuring-version-5-transports.html
The NIO Transport
Same as the TCP transport, except that the New /O(NIO) package is used, which may provide better performance. The Java NIO package should not be confused with IBM's AlO4Jpackage.
To switch from TCP to Nlo, simply change the scheme portion of the URl. Here's an example as defined within a broker's XML configuration file.
<broker> ... <transportConnectors> <transportConnector name="nio" uri="nio://0.0.0.0:61616"/> </<transportConnectors> ... </broker>
3) AMQP protocol
That is, Advanced Message Queuing Protocol, an application layer standard advanced message queuing protocol that provides unified messaging services, is a development of the application layer protocol.
Release standards, designed for message-oriented middleware. Clients and message middleware based on this protocol can transmit messages, and are not affected by different products of client/middleware.
Restrictions on development language and other conditions.
ActiveMQ supports the AMQP 1.0 protocol which is an OASIS standard.
Availability
Available from ActiveMQ version 5.8 onward.
Enabling the ActiveMQ Broker for AMQP
To enable AMQP protocol support on the broker add the following transport connector Configuration referencing the amqp scheme in its URl:
<transportConnectors> <transportconnector name="amqp"uri="amqp://0.0.0.0:5672"/> </transportConnectors>
It is enabled in the default ActiveMQ server configuration.For more help see Run Broker.
(4) MQTT protocol
MQTT (Message Queuing Telemetry Transport) is an instant messaging protocol developed by IBM, which may become the Internet of Things
important parts of. The protocol supports all platforms and can connect almost all networked objects to the outside, and can be used as sensors and actuators (such as communication
The communication protocol of connecting houses via Twitter).
Too lazy to read the official website version: https://s2.ax1x.com/2019/08/29/mL4W38.png
Enabling the ActiveMQ Broker for MQTT
Its very easy to enable ActiveMQ for MQTT. Just add a connector to the broker using the MQTT URL.
<transportConnectors> <transportConnector name="mqtt" uri="mqtt://localhost:1883"/> </transportConnectors>
(5)Secure Sockets Layer Protocol(SSL)
URL form of connection: ssl://hostname:port? key=value
2. Transport Connector configuration example:
<transportConnectors> <transportConnector name="ssl" uri="ssl://localhost:61618?trace=true"/> </transportConnectors>
6) STORM agreement
STOMP, Streaming Text Orientated Message Protocol, is a Streaming Text Orientated Message Protocol. It is a kind of Message Oriented Message Protocol (MOM).
Middleware, a simple text protocol designed by message-oriented middleware.
Visit the official website: https://activemq.apache.org/stomp
(7) WebSocket-ws protocol
Or visit the official web cafe: https://activemq.apache.org/websockets
2.3, NIO performance enhancement
(1) After configuring NIO, the performance should be ok. Is there any further optimization?
The URI format header starts with "nio", indicating that this port uses the NIO network IO model based on the TCP protocol. But this setting method can only make this end
The port supports the Openwire protocol. How to make this port support the NIO network IO model and make it support multiple protocols?
(2) Use the auto keyword
It is still the official website to visit: https://activemq.apache.org/auto
Enabling AUTO over NIO
To configure ActiveMQ auto wire format detection over an NIO TCP connection use the auto+nio transport prefix. For example, add the following transport configuration in your XML file:
3) Use the "+" symbol to set various characteristics for the port
If you do not specify ActiveMQ's network listening ports, then these ports will use the BIO network IO model. (OpenWire, STOMP, AMQP..
…)
So in order to improve the network throughput performance of a single node first, I need to clearly specify the Active network IO model, as shown below: URI format header starts with "nio", table
Shows that this port uses the NIO network IO model based on the TCP protocol.