Activemq配置文件详解
Activemq目錄
Activemq根目錄下目錄列表:
-rw-r--r-- 1 activemq activemq 40580 Aug 2 2016 LICENSE -rw-r--r-- 1 activemq activemq 3334 Aug 2 2016 NOTICE -rw-r--r-- 1 activemq activemq 2610 Aug 2 2016 README.txt -rwxr-xr-x 1 activemq activemq 16195019 Aug 2 2016 activemq-all-5.14.0.jar drwxr-xr-x 5 activemq activemq 147 Jul 3 2019 bin drwxr-xr-x 2 activemq activemq 4096 Jul 3 2019 conf drwxrwxrwx 3 root root 77 Sep 1 05:28 data drwxr-xr-x 2 activemq activemq 76 Jul 3 2019 docs drwxr-xr-x 7 activemq activemq 71 Jul 3 2019 examples drwxr-xr-x 6 activemq activemq 4096 Jul 3 2019 lib drwxr-xr-x 4 activemq activemq 136 Sep 1 05:28 tmp drwxr-xr-x 6 activemq activemq 95 Jul 3 2019 webapps drwxr-xr-x 3 activemq activemq 18 Jul 3 2019 webapps-demo bin----存放的是腳本文件 conf----存放的是基本配置文件 data----存放的是日志文件 docs----存放的是說明文檔 examples----存放的是簡單的實例 lib----存放的是activemq所需jar包 webapps----用于存放項目的目錄bin目錄
bin目錄存儲腳本文件以及程序文件
-rwxr-xr-x 1 activemq activemq 21446 Aug 2 2016 activemq -rwxr-xr-x 1 activemq activemq 6189 Aug 2 2016 activemq-diag -rw-r--r-- 1 activemq activemq 15995 Aug 2 2016 activemq.jar -rw-r--r-- 1 activemq activemq 4884 Aug 2 2016 env drwxr-xr-x 2 activemq activemq 78 Jul 3 2019 linux-x86-32 drwxr-xr-x 2 activemq activemq 78 Jul 3 2019 linux-x86-64 drwxr-xr-x 2 activemq activemq 82 Jul 3 2019 macosx -rw-r--r-- 1 activemq activemq 83820 Aug 2 2016 wrapper.jarconf目錄
存儲配置文件。
-rw-r--r-- 1 activemq activemq 5911 Aug 2 2016 activemq.xml # -rw-r--r-- 1 activemq activemq 592 Aug 2 2016 broker-localhost.cert -rw-r--r-- 1 activemq activemq 1370 Aug 2 2016 broker.ks -rw-r--r-- 1 activemq activemq 665 Aug 2 2016 broker.ts -rw-r--r-- 1 activemq activemq 1357 Aug 2 2016 client.ks -rw-r--r-- 1 activemq activemq 665 Aug 2 2016 client.ts -rw-r--r-- 1 activemq activemq 1172 Aug 2 2016 credentials-enc.properties -rw-r--r-- 1 activemq activemq 1121 Aug 2 2016 credentials.properties -rw-r--r-- 1 activemq activemq 962 Aug 2 2016 groups.properties -rw-r--r-- 1 activemq activemq 1011 Aug 2 2016 java.security -rw-r--r-- 1 activemq activemq 1087 Aug 2 2016 jetty-realm.properties -rw-r--r-- 1 activemq activemq 7795 Aug 2 2016 jetty.xml -rw-r--r-- 1 activemq activemq 965 Aug 2 2016 jmx.access -rw-r--r-- 1 activemq activemq 964 Aug 2 2016 jmx.password -rw-r--r-- 1 activemq activemq 3084 Aug 2 2016 log4j.properties -rw-r--r-- 1 activemq activemq 1207 Aug 2 2016 logging.properties -rw-r--r-- 1 activemq activemq 1016 Aug 2 2016 login.config -rw-r--r-- 1 activemq activemq 961 Aug 2 2016 users.propertiesdata目錄
data目錄存放的是日志文件
-rw-r--r-- 1 activemq activemq 199757 Sep 6 03:10 activemq.log #啟動日志文件 -rw-r--r-- 1 activemq activemq 2 Sep 1 05:28 activemq.pid #進程id文件 -rw-r--r-- 1 activemq activemq 0 Sep 1 05:28 audit.log drwxr-xr-x 2 activemq activemq 160 Sep 3 18:56 kahadb #使用kahadb 作為存儲kahadb目錄
-rw-r--r-- 1 activemq activemq 33554432 Sep 2 03:05 db-1.log -rw-r--r-- 1 activemq activemq 33554432 Sep 2 03:26 db-2.log -rw-r--r-- 1 activemq activemq 147632 Sep 2 03:14 db-3.log -rw-r--r-- 1 activemq activemq 33554432 Sep 3 18:55 db-4.log -rw-r--r-- 1 activemq activemq 6070512 Sep 2 03:29 db-5.log -rw-r--r-- 1 activemq activemq 33554432 Sep 6 03:19 db-6.log -rw-r--r-- 1 activemq activemq 9208023 Sep 3 18:57 db-7.log -rw-r--r-- 1 activemq activemq 6901760 Sep 6 03:19 db.data -rw-r--r-- 1 activemq activemq 1239400 Sep 6 03:19 db.redo -rw-r--r-- 1 activemq activemq 8 Sep 1 05:28 lock說明:
- db.data:它是消息的索引文件。本質上是B-Tree的實現,使用B-Tree作為索引指向db-*.log里面存儲的消息。
- db-*.log: 存儲消息的內容。對于一個消息而言,不僅僅有消息本身的數據(message data),而且還有(Destinations、訂閱關系、事務…)。data log以日志形式存儲消息,而且新的數據總是以APPEND的方式追加到日志文件末尾。
- db.redo:主要用來進行消息恢復。edo log的原理用到了“Double Write”。
- lock:鎖定數據庫
docs目錄
docs目錄存放的是說明文檔
examples
存放的是簡單
./amqp/ ./amqp/java #java示例 ./amqp/python #python示例./conf/ ./conf/activemq-demo.xml ./conf/activemq-dynamic-network-broker1.xml ./conf/activemq-dynamic-network-broker2.xml ./conf/activemq-jdbc-performance.xml ./conf/activemq-jdbc.xml ./conf/activemq-leveldb-replicating.xml ./conf/activemq-mqtt.xml ./conf/activemq-scalability.xml ./conf/activemq-security.xml ./conf/activemq-specjms.xml ./conf/activemq-static-network-broker1.xml ./conf/activemq-static-network-broker2.xml ./conf/activemq-stomp.xml ./conf/activemq-throughput.xml ./conf/activemq.xml ./conf/camel.xml ./conf/jetty-demo.xml ./conf/log4j.properties ./conf/resin-web.xml ./conf/web.xml./mqtt #mqtt 協議 java代碼 ./mqtt/java ./mqtt/websocket #mqtt 協議 websocket./openwire/ ./stomplib
存放的是activemq所需jar包
webapps
用于存放項目的目錄
Activemq配置文件
主配置
activemq.xml
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"><!-- Allows us to use system properties as variables in this configuration file --><!--允許在此配置文件中使用系統屬性作為變量被引用。--><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><value>file:${activemq.conf}/credentials.properties</value></property></bean><!-- Allows accessing the server log --><bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"lazy-init="false" scope="singleton"init-method="start" destroy-method="stop"></bean><!--The <broker> element is used to configure the ActiveMQ broker.--><broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"><destinationPolicy><policyMap><policyEntries><policyEntry topic=">" ><!-- The constantPendingMessageLimitStrategy is used to preventslow topic consumers to block producers and affect other consumersby limiting the number of messages that are retainedFor more information, see:http://activemq.apache.org/slow-consumer-handling.html--><pendingMessageLimitStrategy><constantPendingMessageLimitStrategy limit="1000"/></pendingMessageLimitStrategy></policyEntry></policyEntries></policyMap></destinationPolicy><!--The managementContext is used to configure how ActiveMQ is exposed inJMX. By default, ActiveMQ uses the MBean server that is started bythe JVM. For more information, see:http://activemq.apache.org/jmx.html--><managementContext><managementContext createConnector="false"/></managementContext><!--Configure message persistence for the broker. The default persistencemechanism is the KahaDB store (identified by the kahaDB tag).For more information, see:http://activemq.apache.org/persistence.html--><!--配置持久化適配器,默認為kahaDB。支持:JDBC,文件系統(AMQ),levelDB--><persistenceAdapter><kahaDB directory="${activemq.data}/kahadb"/><!-- JDBC<jdbcPersistenceAdapter dataSource="#my-ds"/> --><!-- AMQ<amqPersistenceAdapter directory="${activemq.base}/activemq-data" maxFileLength="32mb"/>--></persistenceAdapter><!--The systemUsage controls the maximum amount of space the broker willuse before disabling caching and/or slowing down producers. For more information, see:http://activemq.apache.org/producer-flow-control.html--><systemUsage><systemUsage><memoryUsage><memoryUsage percentOfJvmHeap="70" /></memoryUsage><storeUsage><storeUsage limit="100 gb"/></storeUsage><tempUsage><tempUsage limit="50 gb"/></tempUsage></systemUsage></systemUsage><!--The transport connectors expose ActiveMQ over a given protocol toclients and other brokers. For more information, see:http://activemq.apache.org/configuring-transports.html傳輸連接器通過給定的協議將ActiveMQ公開給客戶和其他經紀人。--><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&wireFormat.maxFrameSize=104857600"/><transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/></transportConnectors><!-- destroy the spring context on shutdown to stop jetty --><shutdownHooks><bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /></shutdownHooks></broker><!--Enable web consoles, REST and Ajax APIs and demosThe web consoles requires by default login, you can disable this in the jetty.xml fileTake a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details--><import resource="jetty.xml"/></beans> <!-- END SNIPPET: example -->broker節點
| brokerName | Str | localhost | 機器名網絡內唯一 |
| persistent | Boolean | true | 是否持久化。 true表示需要持久化,需要與元素persistenceAdapter結合使用 false表示不持久化 重啟后消息丟失 且十分消耗內存 |
| dataDirectory | Str | ${activemq.data} | 默認持久化數據的目錄 |
| deleteAllMessagesOnStartup | Boolean | false | 啟動時是否清空持久化的消息 |
| enableStatistics | Boolean | true | 是否啟用數據收集 |
persistenceAdapter節點
JDBC:https://activemq.apache.org/jdbc-support
AMQ:https://activemq.apache.org/amq-message-store
KahaDB:https://activemq.apache.org/kahadb 。支持多KahaDB設置,不同隊列使用不同實例。
levelDB:https://activemq.apache.org/leveldb-store
訪問Activmq賬戶
<broker><plugins><!-- anonymousAccessAllowed :支持匿名訪問 --><simpleAuthenticationPlugin anonymousAccessAllowed="false"> <users><authenticationUser username="system" password="manager" groups="users,admins"/><authenticationUser username="user" password="password" groups="users"/><authenticationUser username="guest" password="password" groups="guests"/></users></simpleAuthenticationPlugin><!-- 分別設置不同topic,queue的權限--><authorizationPlugin><map><authorizationMap><authorizationEntries><authorizationEntry queue=">" read="admins" write="admins" admin="admins" /><authorizationEntry queue="USERS.>" read="users" write="users" admin="users" /><authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" /><authorizationEntry queue="TEST.Q" read="guests" write="guests" /><authorizationEntry topic=">" read="admins" write="admins" admin="admins" /><authorizationEntry topic="USERS.>" read="users" write="users" admin="users" /><authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" /><authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/></authorizationEntries></authorizationMap></map></authorizationPlugin></plugins> </broker>用戶名、密碼等可以引用*.properties文件中的變量。例如:
transports
傳輸連接器通過給定的協議將ActiveMQ公開給客戶和其他broker。
主要屬性包括name、uri
systemUsage
配置系統資源使用情況,包括內存、存儲、臨時存儲。
它主要控制的是當系統資源超過限定時,會控制TCP的流量。數據流會降低速度,producer會被阻塞。具體的行為可以配置。
可配置屬性:
- sendFailIfNoSpace:true/false。空間不夠直接失敗。
- sendFailIfNoSpaceAfterTimeout : 空間不夠直接失敗的超時設置(指定時間后才失敗)
從5.15.x 存儲空間支持百分比。
networks
指定activemq broker的服務發現方式。包括:static
消息Destination策略
<destinationPolicy><policyMap><policyEntries><!--指定策略應用的topic。僅限非持久化topic --><policyEntry topic=">" > <!-- The constantPendingMessageLimitStrategy is used to preventslow topic consumers to block producers and affect other consumersby limiting the number of messages that are retainedFor more information, see:http://activemq.apache.org/slow-consumer-handling.html--><!--用于指定避免慢消費者阻塞生產者的策略。 --><pendingMessageLimitStrategy><constantPendingMessageLimitStrategy limit="1000"/></pendingMessageLimitStrategy><!--可以設置很多不同用途的策略 --><dispatchPolicy> <roundRobinDispatchPolicy/> </dispatchPolicy> <subscriptionRecoveryPolicy> <lastImageSubscriptionRecoveryPolicy/> </subscriptionRecoveryPolicy></policyEntry></policyEntries></policyMap></destinationPolicy>pendingMessageLimitStrategy策略:
- ConstantPendingMessageLimitStrategy:
- PrefetchRatePendingMessageLimitStrategy:
屬性文件
-
credentials.properties
定義憑據
-
credentials-enc.properties
-
定義加密的憑據
?
安全配置
管理端配置
jetty.xml
Jetty 是一個開源的servlet容器,它為基于Java的web內容,例如JSP和servlet提供運行環境。
Activemq管理端使用Jetty作為內嵌容器。使用Spring框架提供http服務。
<!--An embedded servlet engine for serving up the Admin consoles, REST and Ajax APIs andsome demos Include this file in your configuration to enable ActiveMQ web componentse.g. <import resource="jetty.xml"/>--> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><bean id="securityLoginService" class="org.eclipse.jetty.security.HashLoginService"><property name="name" value="ActiveMQRealm" /><property name="config" value="${activemq.conf}/jetty-realm.properties" /></bean><!-- 訪問系統的權限的功能,具有的角色 --><bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint"><property name="name" value="BASIC" /><!-- 指定需要的角色--><property name="roles" value="user,admin" /><!-- set authenticate=false to disable login --><!-- true表示需要用戶登錄 --><property name="authenticate" value="true" /></bean><!-- 需要管理員權限的功能 --><bean id="adminSecurityConstraint" class="org.eclipse.jetty.util.security.Constraint"><property name="name" value="BASIC" /><property name="roles" value="admin" /><!-- set authenticate=false to disable login --><property name="authenticate" value="true" /></bean><bean id="securityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping"><property name="constraint" ref="securityConstraint" /><property name="pathSpec" value="/api/*,/admin/*,*.jsp" /></bean><bean id="adminSecurityConstraintMapping" class="org.eclipse.jetty.security.ConstraintMapping"><property name="constraint" ref="adminSecurityConstraint" /><property name="pathSpec" value="*.action" /></bean><bean id="rewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler"><property name="rules"><list><bean id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule"><property name="pattern" value="*"/><property name="name" value="X-FRAME-OPTIONS"/><property name="value" value="SAMEORIGIN"/></bean></list></property></bean><bean id="secHandlerCollection" class="org.eclipse.jetty.server.handler.HandlerCollection"><property name="handlers"><list><ref bean="rewriteHandler"/><bean class="org.eclipse.jetty.webapp.WebAppContext"><property name="contextPath" value="/admin" /><property name="resourceBase" value="${activemq.home}/webapps/admin" /><property name="logUrlOnStart" value="true" /></bean><bean class="org.eclipse.jetty.webapp.WebAppContext"><property name="contextPath" value="/api" /><property name="resourceBase" value="${activemq.home}/webapps/api" /><property name="logUrlOnStart" value="true" /></bean><bean class="org.eclipse.jetty.server.handler.ResourceHandler"><property name="directoriesListed" value="false" /><property name="welcomeFiles"><list><value>index.html</value></list></property><property name="resourceBase" value="${activemq.home}/webapps/" /></bean><bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"><property name="serveIcon" value="false" /></bean></list></property></bean> <bean id="securityHandler" class="org.eclipse.jetty.security.ConstraintSecurityHandler"><property name="loginService" ref="securityLoginService" /><property name="authenticator"><bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator" /></property><property name="constraintMappings"><list><ref bean="adminSecurityConstraintMapping" /><ref bean="securityConstraintMapping" /></list></property><property name="handler" ref="secHandlerCollection" /></bean><bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"></bean><!--host,端口管理 --><bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start"><!-- the default port number for the web console --><property name="host" value="0.0.0.0"/><property name="port" value="8161"/></bean><bean id="Server" depends-on="jettyPort" class="org.eclipse.jetty.server.Server"destroy-method="stop"><property name="handler"><bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"><property name="handlers"><list><ref bean="contexts" /><ref bean="securityHandler" /></list></property></bean></property></bean><bean id="invokeConnectors" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"><property name="targetObject" ref="Server" /><property name="targetMethod" value="setConnectors" /><property name="arguments"><list><bean id="Connector" class="org.eclipse.jetty.server.ServerConnector"><constructor-arg ref="Server" /><!-- see the jettyPort bean --><property name="host" value="#{systemProperties['jetty.host']}" /><property name="port" value="#{systemProperties['jetty.port']}" /></bean><!--Enable this connector if you wish to use https with web console--><!-- bean id="SecureConnector" class="org.eclipse.jetty.server.ServerConnector"><constructor-arg ref="Server" /><constructor-arg><bean id="handlers" class="org.eclipse.jetty.util.ssl.SslContextFactory"><property name="keyStorePath" value="${activemq.conf}/broker.ks" /><property name="keyStorePassword" value="password" /></bean></constructor-arg><property name="port" value="8162" /></bean --></list></property></bean><bean id="configureJetty" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"><property name="staticMethod" value="org.apache.activemq.web.config.JspConfigurer.configureJetty" /><property name="arguments"><list><ref bean="Server" /><ref bean="secHandlerCollection" /></list></property></bean><bean id="invokeStart" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="configureJetty, invokeConnectors"><property name="targetObject" ref="Server" /><property name="targetMethod" value="start" /> </bean></beans>jetty-realm.properties
存儲登錄用戶的信息
# Defines users that can access the web (console, demo, etc.) # username: password [,rolename ...] admin: admin, admin user: user, userJAAS身份驗證
users.properties
存儲用戶名和密碼。格式:用戶名=密碼。
admin=admingroups.properties
定義用戶組包括哪些用戶。用戶組=用戶1,用戶2(多個用戶中間用逗號隔開)
admins=adminlogin.config
用于登錄的配置。
指定使用的屬性文件:users.properties、groups.properties
activemq {org.apache.activemq.jaas.PropertiesLoginModule requiredorg.apache.activemq.jaas.properties.user="users.properties"org.apache.activemq.jaas.properties.group="groups.properties"; };憑據
-
broker-localhost.cert
-
broker.ks
-
broker.ts
-
client.ks
-
client.ts
java.security
JMX配置
jmx.access
admin readwritejmx.password
admin activemq日志配置
log4j.properties
logging.properties
附錄
參考
密碼加密:https://activemq.apache.org/encrypted-passwords
安全:https://activemq.apache.org/security
transport:https://activemq.apache.org/configuring-transports
networks:https://activemq.apache.org/networks-of-brokers , http://www.javashuo.com/article/p-fiubjedj-np.html
KahaDB參數說明
| archiveCorruptedIndex | false | If true, 啟動時歸檔損壞的index(非刪除)。 |
| archiveDataLogs | false | If true, 從data log 移動消息到 歸檔目錄,而不是刪除 |
| checkForCorruptJournalFiles | false | If true, 啟動時檢查損壞journal日志,并嘗試修復。 |
| checkpointInterval | 5000 | Time (ms) before check-pointing the journal。checkpoint的間隔時間,默認是5000。 |
| checksumJournalFiles | true | 是否為每個消息日志文件提供checksum。在ActiveMQ 5.9.0之前默認值是:false. |
| cleanupInterval | 30000 | 在檢查到不再使用的消息后,在執行刪除消息前的時間(ms),默認30000。 |
| compactAcksAfterNoGC | 10 | 從ActiveMQ 5.14.0開始:當啟用確認壓縮功能時,此值控制必須完成的存儲GC周期數,在壓縮邏輯被觸發之前不會清除其他文件,從而可能將跨日志文件的舊確認壓縮到新日志中文件。值設置越低,壓縮可能發生得越快,如果經常運行,可能會影響性能。 |
| compactAcksIgnoresStoreGrowth | false | 從ActiveMQ 5.14.0開始:當啟用確認壓縮功能時,此值控制當存儲仍在增長時是否運行壓縮,或者是否僅在存儲停止增長時(由于達到空閑或存儲限制而發生)。如果啟用,則無論商店仍有空間或處于活動狀態,壓縮都會運行,這會降低整體性能,但會更快地回收空間。 |
| concurrentStoreAndDispatchQueues | true | 是否分發queue消息到客戶端,同時進行存儲 |
| concurrentStoreAndDispatchTopics | false | 是否分發Topic消息到客戶端,同時進行存儲。 Enabling this property is not recommended. |
| directory | activemq-data | The path to the directory to use to store the message store data and log files. |
| directoryArchive | null | 定義消息已經被消費過后,移動data log到的路徑,默認null。 |
| enableAckCompaction | true | 從ActiveMQ 5.14.0:此設置控制商店是否將定期壓縮僅包含消息確認的舊日記日志文件。通過將這些舊的確認壓縮到新的日志日志文件中,可以刪除較舊的文件以釋放空間并允許消息存儲繼續操作而不會達到存儲大小限制。 |
| enableIndexWriteAsync | false | 是否異步寫索引。 |
| enableJournalDiskSyncs | true | 是否保證每個沒有事務的內容,被同步寫入磁盤(JMS持久化的時候需要)。默認為true。 從ActiveMQ 5.14.0: 被 journalDiskSyncStrategy代替. |
| ignoreMissingJournalfiles | false | 是否忽略丟失的消息日志文件 |
| indexCacheSize | 10000 | 內存中緩存索引page的數量 |
| indexDirectory | 從ActiveMQ 5.10.0開始,可以單獨設置KahaDB index files (db.data and db.redo) 的存儲路徑。 | |
| indexWriteBatchSize | 1000 | 批量寫入磁盤的索引page數量 |
| journalDiskSyncInterval | 1000 | 何時執行磁盤同步的時間間隔(ms) journalDiskSyncStrategy=periodic。只有在自上次磁盤同步或日志轉到新日志文件后對日志進行了寫入時,才會執行同步。 |
| journalDiskSyncStrategy | always | 從ActiveMQ 5.14.0:此設置配置磁盤同步策略。可用的同步策略列表(按安全性降低和性能提高的順序):always確保每個日志寫入后跟一個磁盤同步(JMS持久性要求)。這是最安全的選項,但也是最慢的選項,因為它需要在每次寫入消息后進行同步。這相當于不推薦使用的屬性 enableJournalDiskSyncs=true。periodic磁盤將以設定的時間間隔(如果發生寫入)而不是在每次日志寫入之后同步,這將減少磁盤上的負載并且應該提高吞吐量。滾動到新的日志文件時,磁盤也將同步。默認間隔為1秒。默認間隔提供非常好的性能,同時比更安全 never磁盤同步,因為數據丟失的最大值限制為1秒。請參閱journalDiskSyncInterval更改磁盤同步的頻率。never永遠不會顯式調用同步,并且操作系統將刷新到磁盤。這相當于設置deprecated屬性enableJournalDiskSyncs=false。這是最快的選擇,但是最不安全,因為無法確保何時將數據刷新到磁盤。因此,代理失敗時可能會發生消息丟失。 |
| journalMaxFileLength | `32mb | 每個消息數據文件的最大size。 |
| maxAsyncJobs | 10000 | 設置最大的可以存儲的異步消息隊列,默認值10000,可以和concurrent MessageProducers設置成一樣的值。 |
| preallocationScope | entire_journal | 從ActiveMQ 5.14.0:此設置配置如何預分配日記帳數據文件。默認策略使用appender線程在首次使用時預先分配日志文件。 entire_journal_async將在單獨的線程中提前使用preallocate。none禁用預分配。在SSD上,使用 entire_journal_async避免在首次使用時延遲寫入等待預分配。注意:在HDD上,磁盤的額外線程爭用會產生負面影響。因此使用默認值。 |
| preallocationStrategy | sparse_file | 從ActiveMQ 5.12.0:此設置配置代理在需要新日志文件時嘗試預分配日志文件的方式。sparse_file - 設置文件長度,但不會用任何數據填充它。os_kernel_copy - 將預分配委派給操作系統。zeros - 每個預分配的日志文件只包含0x00整個文件。 |
| storeOpenWireVersion | 11 | 確定封送到KahaDB日志的OpenWire命令的版本。在ActiveMQ 5.12.0之前:默認值為6。代理的某些功能取決于較新協議修訂版中存儲在OpenWire命令中的信息,如果將商店版本設置為較低值,這些功能可能無法正常工作。在許多情況下,代理版本大于5.9.0的KahaDB存儲仍然可以被代理讀取,但會導致代理繼續使用較舊的商店版本,這意味著較新的功能可能無法按預期工作。對于在ActiveMQ 5.9.0之前的版本中創建的KahaDB存儲,需要手動設置storeOpenWireVersion="6"以便啟動代理而不會出現錯誤。 |
PolicyEntry
<policyEntry queue=">"> <!-- 死信隊列策略 --><deadLetterStrategy><!--如果你想把非持久的消息發送到死信隊列中。需要設置屬性processNonPersistent=true --><sharedDeadLetterStrategy processNonPersistent="true"/></deadLetterStrategy> </policyEntry> <!--刪除不活動隊列:沒有消息pending并且沒有comsumer的隊列 --> <policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000"/> <policyEntry topic="FOO.>"><!--分發策略: SimpleDispatchPolicy ,PriorityNetworkDispatchPolicy --><dispatchPolicy><roundRobinDispatchPolicy /><strictOrderDispatchPolicy/></dispatchPolicy><subscriptionRecoveryPolicy><lastImageSubscriptionRecoveryPolicy /></subscriptionRecoveryPolicy> </policyEntry>參考:
https://activemq.apache.org/per-destination-policies
https://activemq.apache.org/dispatch-policies
https://activemq.apache.org/subscription-recovery-policy
死信隊列:https://activemq.apache.org/message-redelivery-and-dlq-handling
總結
以上是生活随笔為你收集整理的Activemq配置文件详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java数组的扩容与缩减
- 下一篇: panabit安装