Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze message protocols supported by ActiveMQ

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to carry out ActiveMQ support message protocol analysis, the editor feels very practical, so share with you to learn, I hope you can learn something after reading this article, say no more, follow the editor to have a look.

What protocols does ActiveMQ support?

ActiveMQ supports multiple protocols and transport modes, allowing clients to connect using multiple protocols.

Protocols supported by ActiveMQ: AUTO,OpenWire,AMQP,Stomp,MQTT, etc.

Basic transport methods supported by ActiveMQ: VM,TCP,SSL,UDP,Peer,Multicast,HTTP (S), etc., as well as more advanced Failover,Fanout,Discovery,ZerConf mode

Protocol connection configuration for ActiveMQ

Multiple transports can be used by configuring transportConnectors in the / conf/activemq.xml file of the ActiveMQ installation directory. Official configuration document: http://activemq.apache.org/configuring-transports

Common transmission mode and configuration of ActiveMQ

TPC: because of its reliable transmission, TCP is also one of the most commonly used protocols in ActiveMQ. In the default configuration, the port of the TCP connection is 61616.

TCP configuration format: tcp://hostname:port?key=value

TCP configuration parameter description: when configuring on the server, the parameter should be "transport." At the beginning, the parameter "transport." is omitted when the client connects. Prefix

TCP server configuration example: tcp://localhost:61616?transport.trace=false&transport.soTimeout=6000

TCP client example: tcp://localhost:61616?trace=false&soTimeout=6000

TCP configuration parameters description:

SSL: you can consider using SSL when you need a secure connection, which is suitable for client and broker on the public network.

SSL configuration format: ssl://hostname:61616

SSL client configuration: the JMX client needs to use the ActiveMQSslConnectionFactory class to create a connection. BrokerUrl starts with ssl://.

SSL hostname verification: starting with ActiveMQ 5.15.6, ActiveMQ supports TLS hostname verification, which is enabled by default on the client and not on the server. Server is configured as ssl://localhost:61616?transport.verifyHostName=true client is configured as ssl://localhost:61616?verifyHostName=false

NIO: use Java's NIO approach to improve connections, because NIO uses thread pools and can reuse threads, so you can maintain more connections with fewer threads. If there are a large number of clients, or if the performance bottleneck is in the network transmission, you can consider using NIO connection mode.

NIO configuration format: nio://hostname:port?key=value

NIO is the transmission mode of OpenWire protocol. Other protocols, such as AMQP,MQTT,STOMP, also have the implementation of NIO, which is usually distinguished by adding "+ nio" to the protocol prefix, such as mqtt+nio://localhost:1883.

NIO transport thread usage configuration: starting from 5.15.0, ActiveMQ supports adjusting the transport thread of NIO. You can set the following properties

NIO transport thread usage configuration: properties can be configured in the ActiveMQ installation directory / bin/env, such as:

ACTIVEMQ_OPTS= "$ACTIVEMQ_OPTS-Dorg.apache.activemq.transport.nio.SelectorManager.corePoolSize=2000-Dorg.apache.activemq.transport.nio.SelectorManager.maximumPoolSize=2000-Dorg.apache.activemq.transport.nio.SelectorManager.workQueueCapacity=1024"

NIO+SSL: starting with ActiveMQ version 5.6, NIO can support transport connections used with NIO in the format of nio+ssl://0.0.0.0:61616

UDP: unlike TCP for connection-oriented and reliable byte stream service, UDP is a simple data-oriented transmission connection without TCP's three-way handshake, so its performance is much better than TCP, but at the expense of reliability, it is suitable for messages that do not matter if they are lost.

UDP configuration format: udp://localhost:8123

UDP configuration parameters description:

HTTP (S): if you need to traverse the firewall, you can consider using HTTP (S), but because HTTP (S) is a short connection, the cost of creating a connection is high, so the performance is the worst. Data is transmitted through XML.

HTTP (S) configuration format: http (s): / / localhost:8080?param1=value1¶m2=value2

VM: virtual machine protocol (method direct adjustment). The usage scenario is when client and broker are embedded in the same Java virtual machine, without the overhead of network communication.

VM configuration format: vm://brokerName?marshal=false&broker.persistent=false

VM configuration parameters description:

OpenWire protocol

OpenWire protocol is a cross-language protocol of Apache, which allows access to ActiveMQ from different languages and platforms. It is the default transport protocol for later versions of ActiveMQ 4.x.

OpenWire supports TCP,SSL,NIO,UDP,VM and other transport methods. To configure these connections directly is the OpenWire protocol used. OpenWire has its own configuration parameters, and the client and server configure parameter names through the prefix "wireFormat." It means. Such as: tcp://localhost:61616?wireFormat.cacheEnabled=false

Description of configuration parameters for OpenWire:

MQTT protocol

MQTT (Message Queue Telemetry Transport) message queue telemetry transmission is an instant messaging protocol developed by IBM and has become the standard of Internet of things communication.

MQTT has a simple structure and is more lightweight than other protocols. It is suitable for use in a network environment with limited computing power, low bandwidth and unreliable.

MQTT's publish / subscribe model:

The quality of service (QoS) level is a guaranteed protocol for the delivery of information between the sender and the receiver. MQTT has three QoS levels: at most once (level 0), at least once (level 1), and only once (level 2)

QoS is a major function of MQTT, which makes it easy to communicate in an unreliable network, because even in a very unreliable network, the protocol can control whether the message needs to be retransmitted and ensure that the message arrives. It can also help clients freely choose QoS according to the network environment and program logic.

AUTO protocol

AUTO, automatic detection protocol. Starting from ActiveMQ 5.13.0, ActiveMQ supports protocol format detection, which can automatically detect OpenWire,STOMP,AMQP and MQTT, allowing these four types of clients to share a transport.

The above is how to analyze the message protocol supported by ActiveMQ. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report