欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

消息中间件HornetQ 集群配置

程序员文章站 2022-07-15 15:31:16
...

版本号:hornetq-2.2.14.Final

1. 修改启动脚本 bin/run.sh
a. 将 if [ a"$1" = a ]; then CONFIG_DIR=$HORNETQ_HOME/config/stand-alone/non-clustered;
改为:if [ a"$1" = a ]; then CONFIG_DIR=$HORNETQ_HOME/config/stand-alone/clustered;
b. 打开注释符号并设置正确的 honetq 所在的 ip 地址
export CLUSTER_PROPS="-Djnp.port=1099 -Djnp.rmiPort=1098 -Djnp.host=192.168.1.100
-Dhornetq.remoting.netty.host=192.168.1.100 -Dhornetq.remoting.netty.port=5445"
2. 修改停止脚本 bin/stop.sh
if [ a"$1" = a ]; then CONFIG_DIR=$HORNETQ_HOME/config/stand-alone/non-clustered;
修改为:if [ a"$1" = a ]; then CONFIG_DIR=$HORNETQ_HOME/config/stand-alone/clustered;

 

3.配置消息转储存 config/stand-alone/clustered/hornetq-configuration.xml
<address-settings>
<!--default for catch all-->
<address-setting match="#">
<dead-letter-address>jms.queue.DLQ</dead-letter-address>
<expiry-address>jms.queue.ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<max-size-bytes>104857600</max-size-bytes>
<page-size-bytes>10485760</page-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>PAGE</address-full-policy>
<redistribution-delay>0</redistribution-delay>
</address-setting>
</address-settings>
a. <max-size-bytes>104857600</max-size-bytes> 消息队列使用 100MB 内存存储消息
b. <page-size-bytes>10485760</page-size-bytes> 如果内存用完将消息写入文件,文件大小为 10MB
c. <address-full-policy>PAGE</address-full-policy> 内存用完后的策略是将消息转储到文件

 

4. 配置消息再分配 config/stand-alone/clustered/hornetq-configuration.xml
<cluster-connections>
<cluster-connection name="my-cluster">
<address>jms</address>
<forward-when-no-consumers>false</forward-when-no-consumers>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="dg-group1"/>
</cluster-connection>

</cluster-connections>
a. <forward-when-no-consumers>false</forward-when-no-consumers> 消息不发往没有接收者的服务器
节点
b. <max-hops>1</max-hops> 消息再分配时候最多能跨越几个节点

<address-settings>
<address-setting match="#">
<redistribution-delay>0</redistribution-delay>
</address-setting>
</address-settings>
c. <redistribution-delay>0</redistribution-delay>
队列最后一个接收者关闭后需要等待多长时间再将消息重新分配(毫秒)

5. 消费者零接收缓冲 hornetq-jms.xml
<connection-factory name="ConnectionFactory">
<connectors>
<connector-ref connector-name="netty-connector"/>
</connectors>
<entries>
<entry name="ConnectionFactory"/>
</entries>
<consumer-window-size>0</consumer-window-size>
</connection-factory>
<consumer-window-size>0</consumer-window-size>消费者零接收缓冲

6.开监控权限
<security-settings>
<security-setting match="#">
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="send" roles="guest"/>
</security-setting>
<security-setting match="jms.queue.hornetq.management">
<permission type="manage" roles="guest" />
</security-setting>
</security-settings>

 

7.spring 通过广播查找 hornetq 集群服务器
<bean id="transportConfiguration" class="org.hornetq.api.core.DiscoveryGroupConfiguration">
<constructor-arg index="0" value="231.7.7.7" />
<constructor-arg index="1" value="9876" />
</bean>

  • 消息中间件HornetQ 集群配置
            
    
    博客分类: JMS hornetq JMSHornetQ
  • 大小: 29.9 KB
相关标签: JMS HornetQ