Home > Java > javaTutorial > body text

JMS Active MQ message transmission

巴扎黑
Release: 2017-06-26 11:38:45
Original
1528 people have browsed it

This article uses Active MQ5.6

1. Message Negotiator (Message Broker)

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.

2. Connectors

( 1) Transport Connectors

transportConnectors Connectors: It is to establish the interaction between the broker, the message producer and the message consumer.

Commonly used protocols for transport connectors:

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 optional

Benefits of using TCP protocol

  • Efficient: This protocol connection uses the OpenWire protocol, and the performance is very good by converting the message into a byte stream

  • Availability: TCP is a very widely used network protocol, basically all platforms support it

TCP configuration example conf/activemq.xml:

        <transportConnectors><!--activemq 的默认连接 tcp--><transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/></transportConnectors>
Copy after login

(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

d, NIO configuration instance conf/activemq.xml:

         <transportConnectors><!-- 设置一个NIO的连接--><transportConnector name="nio" uri="nio://0.0.0.0:61617"/></transportConnectors>
Copy after login

(3), UDP

a. The difference between UDP and TCP

  • TCP is a primitive stream delivery protocol, which means The data packets are guaranteed, in other words, the data packets will not be copied or lost. UDP, on the other hand, does not guarantee the delivery of data packets

  • TCP is also a stable and reliable data packet delivery protocol, which means that the data will not be lost. This ensures reliable communication between sender and receiver. On the contrary, UDP is just a link protocol, so it has no reliability.

  • TCP is used in stable and reliable scenarios; UDP is usually used in fast data transfer and reliable In the scenario of data loss, and when ActiveMQ passes through the firewall, only UDP

b. URI form of UDP connection: udp://hostname:port?key=value

c. Configuration example conf/activemq.xml

        <transportConnectors><transportConnector name="udp" uri="udp://localhost:61618"/></transportConnectors>
Copy after login

(4), SSL

Bottom layer It is a TCP protocol, but the transmitted data is encrypted

a. Applicable scenario: MQ is exposed to the external network and requires communication between the client and the broker

b. Usage steps:

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>
Copy after login
b-3. Configure client SSL protocol:

c. URI form of SSL connection: ssl://hostname:port?key=value

d. Configuration example conf/activemq.xml

        <transportConnectors><transportConnector name="ssl" uri="ssl://localhost:61619"/></transportConnectors>
Copy after login
(5) HTTP, HTTPS

a, receive mq messages of http protocol through jetty container

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

e, configuration Example conf/activemq.xml:

     <transportConnectors><transportConnector name="http" uri="http://localhost:8080"/></transportConnectors>
Copy after login
To configure HTTPS, you need to configure the relevant certificate in jetty.xml HTTPS= HTTP+SSL

(2.) Network connector (NetWorkConnectors)

NetWorkConnectors: used for the interaction between Broke and Broke, mainly when deploying ActiveMq cluster.

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template