ActiveMQ(三)ActiveMQ 传输协议

1、ActiveMQ 传输协议

ActiveMQ 支持的 client-broker 通讯协议有:TCP、NIO、UDP、SSL、Http(s)、VM等

1.1 ActiveMQ 传输协议配置

在 ActiveMQ 安装目录下的 conf/activemq.xml 中的 transportConnectors 标签内可以看到下面的实际配置

如果不指定 ActiveMQ 的网络监听端口,这项端口都将使用 BIO 网络 IO 模型

<!--
            The transport connectors expose ActiveMQ over a given protocol to
            clients and other brokers. For more information, see:

            http://activemq.apache.org/configuring-transports.html
        -->
<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>

配置信息

  • URI 描述信息的头部采用协议名称
  • activeMQ 默认消息协议是 openwire,URI 头使用 tcp://

1.2 ActiveMQ 传输协议种类

Transmission Control Protocol (TCP)

  • 默认的 Broker 配置,TCP 的Client 监听端口是 61616
  • 网络传输数据必须要序列化,消息通过 wire protocol 来序列化成字节流。默认把 ActiveMQ 的 wire protocol 叫做 OpenWire
  • TCP 连接的URI 形式:tcp://hostname:port?key=value&key=value
  • tcp 传输优点:
    • 可靠性高,稳定性强
    • 字节流传输,高效
    • 应用广泛,可用性高

New I/O API Protocol(NIO)

  • 与 TCP 协议类似,但允许开发人员对同一资源可以有更多的 client 调用和服务端有更多的负载
  • NIO 连接 URI:nio//hostname:port?key=value

AMQPstompSecure Sockets Layer Protocol (SSL)mqttws

协议描述
TCP默认协议,性能一般
NIO基于 TCP 协议进行了扩和优化,有更好的扩展性
UDP性能比 TCP 协议更好,不具有可靠性
SSL安全连接
HTTP/HTTPS基于 HTTP 或者 HTTPS
VM客户端和代理在同一个 jvm 中运行时,不占用网络通道直接通信,可以使用该方式

1.3 配置 NIO 传输协议

在配置文件中添加

<transportConnectors>
    <transportConnector name="nio" uri="nio://0.0.0.0:61618?trace=true"/>
</transportConnectors>

更改之后连接地址更改协议为 NIO,端口为上面配置中端口地址

URI 格式以 NIO 开头,标识端口只能用 TCP 协议为基础的网络 IO 模型,但是这样设置的话,只能让这个端口支持 Openwire 协议

auto + NIO 配置,多协议适配

<transportConnector name="auto+nio" uri="auto+nio://0.0.0.0:61608?maxnumConnections=1000&amp;wireFormat.maxFrameSize=104857600&amp;org.apache.activema.transport.nio.SelectorManager.corePoolSize=20&amp;org.apache.activemq.transport.nio.SelectorManager.maximumPoolSize=50" />
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一起来搬砖呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值