ActiveMQ配置参考手册
1ActiveMQ Server端配置
1.1设置Broker名字
修改%activemq%/l文件
<broker xmlns=”/schema/core” brokerName="机器名"
  dataDirectory="${activemq.base}/data">
</broker>
1.2设置persistenceAdapter
修改%activemq%/l文件
<persistenceAdapter>
<kahaDB directory="${activemq.base}/data/kahadb"
enableJournalDiskSyncs="false" indexWriteBatchSize="10000"
indexCacheSize="1000"/>
</persistenceAdapter>
1.3设置destinationPolicy
打开%activemq%/l文件,添加如下红配置属性:
<broker xmlns="/schema/core" brokerName="localhost"
  dataDirectory="${activemq.base}/data">
<destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry queue=">" producerFlowControl="false"
memoryLimit="4mb"  >
                  <deadLetterStrategy>
                      <sharedDeadLetterStrategy processExpired="false" />
                  </deadLetterStrategy>
</policyEntry>
<policyEntry topic=">" producerFlowControl="false" memoryLimit="4mb">
                      <!-- you can add other policies too such as these
                        <dispatchPolicy>
                            <strictOrderDispatchPolicy/>
                        </dispatchPolicy>
                        <subscriptionRecoveryPolicy>
                            <lastImageSubscriptionRecoveryPolicy/>
                        </subscriptionRecoveryPolicy>
                      -->
                    </policyEntry>
                </policyEntries>
            </policyMap>
        </destinationPolicy>
…..
</broker>
1.4设置networkConnectors
修改%activemq%/l文件
<broker xmlns="/schema/core" brokerName="localhost"
dataDirectory="${activemq.base}/data">
…..
<networkConnectors>
<networkConnector uri="static:(tcp://<节点IP>:61616? soTimeout=60000)"/>       
</networkConnectors>
…..
</broker>
1.5设置transportConnectors
修改%activemq%/l文件
<broker xmlns="/schema/core" brokerName="localhost"
dataDirectory="${activemq.base}/data">
……
  <transportConnectors>
<transportConnector name="openwire" uri="tcp://<节点ip>:61616"/>
      <transportConnector name="openwirelocal" uri="tcp://127.0.0.1:61616"/>
  </transportConnectors>
……
</broker>
2ActiveMQ Client端连接配置
目前Client端使用Failover协议组合TCP协议的方式连接broker,示例如下:
failover://(tcp://server01:61616 ?soTimeout=60000,tcp:// server02:61616?soTimeout=60000)?randomize=false
可以看到,tcp协议和failover协议分别支持一些不同的连接配置参数。如示例URL中的soTimeout和randomize。
下面就TCP协议和Failover协议的连接配置参数分别进行详细介绍。
2.1TCP连接参数配置
2.1.1The TCP Transport Options
参数名称
默认值
描述
minmumWireFormatVersion
0
The minimum version wireformat that is allowed.
trace
false
Causes all commands that are sent over the transport to be logged
daemon
false
Tells the transport thread to run as a daemon or not. Useful to enable when embedding in a Spring container or a web container to allow the container to shut down properly.
useLocalHost
true
When true, it causes the local machines name to resolve to "localhost".
socketBufferSize
64*1024
Sets the socket buffer size in bytes.
keepAlive
false
When true, enables TCP KeepAlive on the broker connection. Useful to ensure that inactive consumers don't time out.
soTimeout
0
Sets the socket timeout in milliseconds.
connectionTimeout
30000
A non-zero value specifies the connection timeout in milliseconds. A zero value means wait forever for the connection to be established. Negative values are ignored.
wireFormat
default
The name of the WireFormat to use.
wireFormat.*
All the properties with this prefix are used to configure the wireFormat. See Configuring Wire Formats for more information.
closeAsync
true
The false value causes all sockets to be closed synchronously.
soLinger
MIN_INTEGER
When > -1 causes the socket soLinger option to be enabled with this value. When == -1, causes soLinger to be disabled. (from 5.6.0)
maximumConnections
Integer.MAX_VALUE
The maximum number of sockets the broker is allowed to create.
2.1.2The OpenWire Wire Format Options
OpenWire is the default Wire Format that ActiveMQ uses. It provides a highly efficent binary format for high speed messaging. OpenWire options can be configured on a JMS client's connection URI string or on a Brokers transport bind URI.
参数名称
默认值
描述
stackTraceEnabled
true
Should the stack trace of exception that occur on the broker be sent to the client?
tcpNoDelayEnabled
false
Does not affect the wire format, but provides a hint to the peer that TCP nodelay should be enabled on the communications Socket.
cacheEnabled
true
Should commonly repeated values be cached so that less marshalling occurs?
tightEncodingEnabled
true
Should wire size be optimized over CPU usage ?
prefixPacketSize
true
Should the size of the packet be prefixed before each packet is marshalled?
maxInactivityDuration
30000
The maximum inactivity duration (before which the socket is considered dead) in milliseconds. On some platforms it can take a long time for a socket to appear to die, so we allow the broker to kill connections if they are inactive for a period of time. Use by some transports to enable a keep alive heart beat feature. Set to a value <= 0 to disable inactivity monitoring.
maxInactivityDurationInitalDelay
10000
The initial delay in starting the maximum inactivity checks (and, yes, the word 'Inital' is supposed to be misspelled like that)
cacheSize
1024
If cacheEnabled is true, then this specifies the maximum number of values to cached. This property was added in ActiveMQ 4.1
maxFrameSize
104857600
Maximum frame size that can be sent. Added in 5.6.0 with default value of 100 MB, it should help prevent DOS attacks
2.2Failover协议参数配置
The Failover configuration syntax allows you to specify any number of composite uris. The Failover transport randomly chooses one of the composite URI and attempts to establish a connection to it. If it does not succeed or if it subsequently fails, a new connection is established to one of the other uris in the list.
2.2.1The Failover Transport Options
参数名称
默认值
描述
initialReconnectDelay
10
How long to wait before the first reconnect attempt (in ms).
maxReconnectDelay
30000
The maximum amount of time we ever wait between reconnect attempts (in ms).
useExponentialBackOff
true
Should an exponential backoff be used btween reconnect attempts.
backOffMultiplier
2.0
The exponent used in the exponential backoff attempts.
maxReconnectAttempts
0
If not 0, then this is the maximum number of reconnect attempts before an error is sent back to the client.
startupMaxReconnectAttempts
0
If not 0, then this is the maximum number of reconnect attempts before an error is sent back to the client on the first attempt by the client to start a connection, once connected the maxReconnectAttempts option takes precedence.
randomize
true
use a random algorithm to choose the the URI to use for reconnect from the list provided.
backup
false
initialize and hold a second transport connection - to enable fast failover.
timeout
-1
Enables timeout on send operations (in miliseconds) without interruption of reconnection process.
trackMessages
false
keep a cache of in-flight messages that will flushed to a broker on reconnect.
active transport
maxCacheSize
131072
size in bytes for the cache, if trackMessages is enabled.
updateURIsSupported
true
Determines whether the client should accept updates to its list of known URIs from the connected broker. Added in ActiveMQ 5.4.
Notes

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。