ActiveMQ 2 ActiveMQ ReplicationLevelDB

这里只是简述我的配置以及碰到的问题.

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker"
...
        <managementContext>
            <managementContext createConnector="true"/>
        </managementContext>

...
<persistenceAdapter>
                <!-- <kahaDB directory="${activemq.data}/kahadb"/> -->
                <!-- <jdbcPersistenceAdapter  dataSource="#mysql-ds" /> -->
                <replicatedLevelDB
                        directory="${activemq.data}/leveldb"
                        replicas="3"
                        bind="tcp://0.0.0.0:0"
                        zkAddress="192.168.1.210:2181,192.168.1.211:2181,192.168.1.212:2181"
                        zkPath="/activemq/leveldb-stores"
                        hostname="192.168.1.210"
                        sync="local_disk"
                />
</persistenceAdapter>

...
</broker>

要求使用failover协议

引用
failover:(tcp://192.168.1.210:61616,tcp://192.168.1.211:61616,tcp://192.168.1.212:61616)

问题一:

关闭ActiveMQ时异常

引用

ConnectingtoJMXURL:service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

ERROR:java.lang.RuntimeException:Failedtoexecutestoptask.Reason:java.io.IOException:FailedtoretrieveRMIServerstub:javax.naming.ServiceUnavailableException[Rootexceptionisjava.rmi.ConnectException:Connectionrefusedtohost:localhost;nestedexceptionis:java.net.ConnectException:Connectionrefused]

将<managementContextcreateConnector="true"/>改为true,默认是false.

问题二:

测试时使用了3个ActiveMQ集群Master-Slave,比如我的是210,211,212,如果正在使用210为Master(测试方法为访问3台机器的8161端口,哪个可以访问,当前哪个是Master),关闭210,会在MessageProducer.send方法时阻塞,无法正常工作,当210再次启动时,MessageProducer.send方法不再阻塞,但Master可能会变成其他的node,比如211.

解决办法是参照这里

http://blog.csdn.net/srnpr/article/details/17370813?reload

http://www.cnblogs.com/fuhaots2009/p/3478413.html

这两篇是一样的,不知道谁是原创,都粘贴了.

加上sync="local_disk"参数配置

引用

sync

defaultvalue:quorum_mem

Controlswhereupdatesareresidebeforebeingconsideredcomplete.Thissettingisacommaseparatedlistofthefollowingoptions:local_mem,local_disk,remote_mem,remote_disk,quorum_mem,quorum_disk.Ifyoucombinetwosettingsforatarget,thestrongerguaranteeisused.Forexample,configuringlocal_mem,local_diskisthesameasjustusinglocal_disk.quorum_memisthesameaslocal_mem,remote_memandquorum_diskisthesameaslocal_disk,remote_disk

详细配置请参见:http://activemq.apache.org/replicated-leveldb-store.html

相关推荐