This article uses Active MQ5.6
broke: The message exchanger is a container that manages messages . ActiveMQ can create multiple Brokers. When the client interacts with ActiveMQ, it actually interacts with the Broker in ActiveMQ. The Broker is configured in ${MQ_HOME}\conf\activemq.xml.
transportConnectors Connectors: It is to establish the interaction between the broker, the message producer and the message consumer.
Commonly used connection protocols in Active MQ: tcp, udp, nio, ssl, http, https,vm. If you use the SSL protocol, you need to configure a certificate. If you use http or https, you need to use httpclient to send and receive messages.
(1)TCP default protocol
##tcp://hostname:port?key=value&key=value The following parameters are optionalBenefits of using TCP protocol
<transportConnectors><!--activemq 的默认连接 tcp--><transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/></transportConnectors>
(2), NIOa, NIO protocol is similar to TCP protocol, but NIO focuses more on underlying access operations . It allows developers to have more client calls and more load on the server for the same resource.
b. Scenarios suitable for using the NIO protocol:
There may be a large number of Clients connecting to the Broker. Generally, the number of Clients connecting to the Broker is limited by the number of threads in the operating system. Therefore, the implementation of NIO requires fewer threads to run than TCP, so it is recommended to use the NIO protocol
May have a very slow network transmission for the Broker NIO provides better performance than TCP
c, URI of the NIO connection Format: nio://hostname:port?key=value The following parameters are optional
<transportConnectors><!-- 设置一个NIO的连接--><transportConnector name="nio" uri="nio://0.0.0.0:61617"/></transportConnectors>
(3), UDP
a. The difference between UDP and TCP<transportConnectors><transportConnector name="udp" uri="udp://localhost:61618"/></transportConnectors>
(4), SSL
Bottom layer It is a TCP protocol, but the transmitted data is encrypteda. Applicable scenario: MQ is exposed to the external network and requires communication between the client and the broker
b-1. Create SSL protocol:
b-2. Configure Broker SSL protocol conf/activemq.xml:
<sslContext><sslContext keyStore="F:/beifeng/apache-activemq-5.6.0/conf/mybroker.ks" keyStorePassword="test123" /> </sslContext>
<transportConnectors><transportConnector name="ssl" uri="ssl://localhost:61619"/></transportConnectors>
b, used in network environments that only allow basic HTTP services to pass
c. To send/receive messages through httpclient, you need to add additional java packages Httpclient, Xstream, activemq-optional
d, URI: http://hostname:port?key=value
<transportConnectors><transportConnector name="http" uri="http://localhost:8080"/></transportConnectors>
The above is the detailed content of JMS Active MQ message transmission. For more information, please follow other related articles on the PHP Chinese website!