当前位置:网站首页>ActiveMQ knowledge summary of Message Oriented Middleware
ActiveMQ knowledge summary of Message Oriented Middleware
2022-06-22 05:12:00 【Concealed wind】
1、JMS(Java Message Service,Java Message service )
1.1 Definition
Java Message service (Java Message Service, namely JMS) The API is a Java About message-oriented middleware in the platform (MOM) Of API, Used between two applications , Or send a message in a distributed system , Asynchronous communication .Java Message service is a platform independent APl.
1.2 JMS Object model of
| name | describe |
|---|---|
| ConnectionFactory | Connection factory |
| Connection | Connect |
| Session | conversation |
| Destination | Purpose |
| MessageProducer | producer |
| MessageConsumer | consumer |
| Message | news |
| Broker | Examples of Message Oriented Middleware (ActiveMQ) |
1.3 JMS Message model
Point-to-Point (P2P) / Point to point

Publish/Subscribe (Pub/Sub) / The theme ( Publish subscribe )

1.4 JMS Message structure of
The message header 、 Message properties 、 Message body
The message header

Message properties : It can be understood as an additional header of the message , Attribute names can be customized

Message body

2、ActiveMQ Concept
2.1 Definition
ActiveMQ yes Apache Produce , One of the most popular , Powerful open source message bus .
ActiveMQ Is a full support JMS1.1 and J2EE 1.4 canonical JMS Provider Realization , Even though JMS It's been a long time since the standard was issued , however JMS In today's J2EE Application still plays a special role .
2.2 characteristic
- Support for multiple programming languages
- Support multiple transport protocols
- There are many ways to persist
2.3 ActiveMQ Which protocols are supported
- ActiveMQ Support multiple protocol transmission and transmission modes , Allow clients to connect using multiple protocols .
- ActiveMQ Supported protocols : AUTO、 OpenWire、 AMQP、Stomp、 MQTT etc. .
- ActiveMQ Supported basic transmission mode : VM、 TCP、SSL、 UDP 、Peer、 Multicast、 HTTP(S) etc. , And more advanced Failover、Fanout、 Discovery、 ZeroConf The way .
2.4 OpenWire agreement
2.4.1 OpenWire What is the protocol
OpenWire yes Apache A cross language protocol , Allow access to... From different languages and platforms ActiveMQ, yes ActiveMQ 4.x The default transport protocol for later versions .
2.4.2 OpenWire How the protocol is used
OpenWire Support TCP、SSL、 NIO、UDP、VM And other transmission modes , Configure these connections directly , It is used OpenWire agreement ,OpenWire Yes Own configuration parameters , The parameter names configured on the client side and the server side are all through the prefix “wireFormat.” Express .
Example

OpenWire Description of configuration parameters
| attribute | The default value is | describe |
|---|---|---|
| stackTraceEnabled | true | Whether the stack exception that has occurred and tracked should be , adopt Broker Send to client |
| tcpNoDelayEnabled | true | socket Of NoDelay Parameters |
| cacheEnabled | true | If repeated values are cached , So as to reduce the number of groups ( The upcoming sending ) happen |
| tightEncodingEnabled | true | according to CPU usage , Automatically resize transmitted content ( Compression ratio ) |
| prefixPacketSize | true | Before each packet is grouped ( To be sent soon ), Whether the size of each packet should be used as the maximum idle time of prefix connection , In Milliseconds . |
| maxInactivityDuration | 30000 | broker The service will close the timeout connection according to the configuration . At the same time, the connection can also be maintained through the heartbeat mechanism . value <=0 Disable monitoring of active connections . |
| maxlnactivityDurationInitalDelay | 10000 | After the connection is established , How soon to start timeout detection |
| cacheSize | 1024 | If it can be cached , So this specifies the maximum number of caches . In this attribute, the ActiveMQ Of 4.1 Start adding the maximum frame size that can be sent |
| maxFrameSize | MAX_ LONG | Can help prevent OOM DOS attack |
2.5 Why use MQTT agreement
MQTT Its structure is simple , Compared with other message protocols , It's more lightweight . Suitable when the computing power is limited 、 Low bandwidth 、 Unreliable network environment use .
2.5.1 MQTT Publish subscribe model

2.5.2 MQTT Service quality
Service quality (QoS) Level is a guarantee protocol for the delivery of information between the sender and the receiver .MQTT There are three QoS Level :
- One more time (0)
- At least once (1)
- For once (2)
QoS yes MQTT One of the main functions of , It makes it easier to communicate in an unreliable network , Because even in a very unreliable network , The protocol can also control whether the message needs to be retransmitted and ensure that the message arrives . It can also help clients choose freely according to the network environment and program logic QoS.
2.5.3 ActiveMQ How to use MQTT agreement
ActiveMQ Server side configuration
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize= 104857600"/>
</transportConnectors>
MQTT Configuration parameter description
| attribute | The default value is | describe |
|---|---|---|
| maxFrameSize | 268435456 | (v5.12.0) Maximum frame size that can be sent . The agreement is limited to 256MB, Its value cannot be set higher . Can help prevent OOM DOS attack |
Configuration example
<transportConnector name="mqtt" uri="mtt://localhost:1883?wireFormat.maxFrameSize=100000"/>
MQTT Use NIO
<transportConnector name="mgtt+nio" uri="mtt+nio://localhost:1883"/>
MQTT Use NIO + SSL
<transportConnector name="mqtt+nio" uri="mqtt+niossl://localhost:1883"/>
2.5.4 Spring Use MQTT
Spring Integration Provides MQTT Protocol support , adopt Maven Add dependencies to use .
<dependency>
<groupld>org.springframework.integration</groupld>
<artifactld>spring-integration-mqtt</artifactld>
<version>5.1.1.RELEASE</version>
</dependency>
2.6 AUTO What is the protocol
AUTO Automatic detection protocol from ActiveMQ 5.13.0 Start ,ActiveMQ Start to support protocol format detection , Can automatically detect OpenWire、STOMP、 AMQP and MQTT. Allow this 4 Two types of clients share a transport
AUTO Use TCP
<transportConnector name="auto" uri="auto://localhost:5671"/>
AUTO Use SSL
<transportConnector name="auto+ssl" uri="autssl://localhost:5671"/>
AUTO Use NIO
<transportConnector name="auto+nio" uri="auto+nio://localhost:5671"/>
AUTO Use NIO+SSL
<transportConnector name="auto+nio+ssl" uri="auto+nioss://localhost:5671"/>
3、ActiveMQ High availability cluster solution
3.1 ActiveMQ What are the cluster deployment methods
| Master-Slave Deployment way | Broker-Cluster Deployment way | Master-Slave And Broker-Cluster Combined deployment mode |
|---|
3.2 Master-Slave Deployment way
Share the same file system

Share the same database

3.3 Broker-Cluster Deployment way

3.4 Master-Slave And Broker-Cluster Combined deployment mode

4、ActiveMQ Persistence mechanism
4.1 Queue Type of persistence mechanism

4.2 Topic Type of persistence mechanism

4.3 storage
4.3.1 JDBC The way
Store the message in the database , for example : Mysql、 SQL Server、Oracle、 DB2 etc.
| advantage | shortcoming |
|---|---|
| Easy to manage | Low performance |
| Can support strong consistency | / |
4.3.2 AMQ The way
File based storage , It has the characteristics of fast write speed and easy recovery , But because it takes too long to rebuild the index , And the index file takes up too much disk space , So it is not recommended to use .
| advantage | shortcoming |
|---|---|
| Performance is higher than JDBC | Index takes up a large amount of disk space |
| / | Rebuilding the index is very slow |
4.3.3 LevelDB The way
LevelDB yes Google Developed a set of high-performance class libraries for persistent data .LevelDB It's not a - Services , Users need to implement Server. It's a single process service , Capable of handling billions of scale Key-Value Type data , It takes up little memory .
characteristic
- be based on K-V Storage
- Key Values are stored in order
- The operation interface is simple
- Support data snapshot
- Support data compression
L evelDB Structure

ActiveMQ To configure LevelDB: Modify the configuration file ${ACTIVEMQ_ HOME}/conf/activemq.xml
<persistenceAdapter>
<levelDB directory="${activemq.data}/activemq-data"/>
</persistenceAdapter>
5、ActiveMQ Transaction implementation mechanism
ActiveMQ Transactions achieve ultimate consistency
The producer side implementation mechanism is as follows :

The implementation mechanism of the consumer side is as follows :

边栏推荐
- Web design and production final assignment report - minority music website
- Restframework read and non read sequence processing
- mysql day02课堂笔记
- Target detection algorithm based on deep learning interview essential (rcnn~yolov5)
- 10 "no no no" redis interview questions
- Monorepo silk slide methodology: reference module hot update
- Pull down refresh, push up load (easy to use, finally)
- Go learning (I. Basic Grammar)
- The application of RPC technology and its framework sekiro in crawler reverse, encrypting data is a shuttle!
- Remote Dictionary Server(Redis)——基于 KV 结构的作为 Cache 使用的 NoSQL 数据库管理系统
猜你喜欢

数据库---基础知识

使用keytool从.jks文件获取SSL certificate

厉害了!淮北两企业获准使用地理标志产品专用标志
![[fault diagnosis] CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace B](/img/f3/86bc79d7b2fb0a7f5ab77d5bbbeb18.png)
[fault diagnosis] CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace B

The Impossible Triangle of NLP?

9 practical shell scripts, recommended collection!

Virtual address space

Flynk deployment mode summary

LeetCode——二叉搜索树的第k大节点(借助中序遍历)

A domestic developer opened the "programmer's Guide to cooking" and became popular!
随机推荐
Lua notes
Kubernetes——部署应用到集群中
numpy库常用知识整理
Monorepo Sliding methodology: Reference module Hot Update
[details] domestic website filing process and steps
The yarn deployment mode depends on the pre upload settings
Getting the return value of DPI function is always 96 | getting the return value of DPI function is incorrect | why the return value of getdpiformonitor/getdevicecaps is incorrect
[scientific research notes] about using the downsampling multiple of openslide cut
[scientific research notes] focal loss
Geographic location type of redis
Gateway uses global filter for token verification
Leetcode -- the kth largest node of the binary search tree (traversal by means of middle order)
QT save qtextedit memory to Txt file
C语言数据类型转换规则(隐式转换+显式转换)
Compilation des connaissances communes de la base de données numpy
Idea创建方法时,使用注解提示方法参数(param)、返回值(return)、方法作用(Description)
Liunx virtual machine environment uses docker to install Oracle database and Navicat to connect
Recruiters - issue 23
【chrome】 谷歌小技巧 谷歌浏览器 自带 滚动截图(全屏截图)
Pull down refresh, push up load (easy to use, finally)