ActiveMQ (08): Transport Protocol and Configuration Supported by ActiveMQ

I. Brief Introduction

Connector: ActiveMQ provides the function of connecting and communicating. Including: client-to-broker, broker-to-broker. ActiveMQ allows clients to connect using multiple protocols.


Configure Transport Connector, in conf/activemq.xml, roughly as follows:

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>


The client-broker communication protocol supported by ActiveMQ is as follows:

 1:TCP: This protocol is also used by default.

 2: NIO 

 3: UDP 

 4: SSL 

 5: Http(s)

 6:VM: If the client and broker are in a virtual machine, they communicate in the VM through the VM protocol, thus reducing the overhead of network transmission.

II. Configuration

2.1 TCP

<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>

This is the default Broker configuration, TCP's Client listening port is 6161616.


OpenWire: Data must be serialized before it can be transmitted over the network. Messages are serialized into byte streams through a wire protocol. By default, ActiveMQ calls wire protocol

       OpenWire, whose goal is to facilitate efficient and fast data interaction on the network.

The URI form of TCP connection: tcp://hostname:port?Key=value&key=value, the bold part is necessary.

Advantages of TCP transmission:

 (1) TCP protocol has high reliability and stability in transmission

 (2) Efficiency: byte stream transfer, high efficiency

 (3) Effectiveness and availability: widely used to support any platform

For all configurable parameters for the Transport protocol, see http://activemq.apache.org/configuring-version-5-transports.html

2.2 NIO

1. NIO protocol is similar to TCP protocol, but NIO focuses more on the underlying access operations. It allows developers to have more client calls and more load on the server side for the same resource.

2. Scenarios suitable for using NIO protocol:

(1) There may be a large number of Clients to link to Broker. Generally, a large number of Clients to link to Broker is limited by the number of threads of the operating system. Therefore,

   NIO implementations require fewer threads to run than TCP implementations, so NIO protocol is recommended.

(2) There may be a very slow network transmission NIO for Broker that provides better performance than TCP.

3. URI form of NIO connection: nio://hostname:port?key=value

<transportConnectors>
    <transportConnector name="tcp" uri="tcp://localhost:61616?trace=true" />
    <transportConnector name="nio" uri="nio://localhost:61618?trace=true" />
</transportConnectors>

The above configuration demonstrates a TCP protocol listening on port 61616 and a NIO protocol listening on port 6161618.

Keywords: Java network xml SSL Apache

Added by pspeakman on Tue, 09 Jul 2019 01:52:59 +0300