A. Activemq的stomp怎麼能一條一條地接收消息,而不是全部接收
ActiveMQ另問題要軟體能掛掉掛掉怕怕掛掉信息給丟所本節析幾種持久化式:
、持久化文件
ActiveMQ默認支持種式要發消息設置消息持久化
打安裝目錄配置文件:
D:\ActiveMQ\apache-activemq\conf\activemq.xml越80行發現默認配置滲御遲項:
注意使用kahaDB基於文件支持事務消息存儲器靠高性能擴展消息存儲器
設計初衷使用簡單並盡能快KahaDB索引使用transaction log並且所destination使用index測試表明:用於產環境支持1萬active connection每connection獨立queue該表現已經叢李足矣應付部需求
再發送消息候改變第二參數:
MsgDeliveryMode.Persistent
Message保存式2種
PERSISTENT:保存磁碟consumer消費message刪除
NON_PERSISTENT:保存內存消費message清除
注意:堆積消息太能導致內存溢
打產者端發送消息:
wps30F4.tmp
啟消費者端同管理界面查看:
wps3105.tmp
發拆兄現消息等待沒持久化ActiveMQ宕機重啟消息丟失我現修改文件持久化重啟ActiveMQ消費者仍能夠收消息
wps3106.tmp
二、持久化資料庫
我支持Mysql例先載mysql-connector-java-5.1.34-bin.jar包放:
D:\ActiveMQ\apache-activemq\lib目錄
打並修改配置文件:
復制代碼
<beans
xmlns=""
xmlns:xsi=""
xsi:schemaLocation=" /spring-beans.xsd
/activemq-core.xsd">
file:${activemq.conf}/credentials.properties
<bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
<!--
The element is used to configure the ActiveMQ broker.
-->
<!-- The is used to prevent
slow topic consumers to block procers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
-->
<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:
-->
<!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see:
-->
<!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down procers. For more information, see:
-->
<!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see:
-->
<!--
Enable web consoles, REST and Ajax APIs and demos
The web consoles requires by default login, you can disable this in the jetty.xml file
Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
-->
-