You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by bu...@apache.org on 2016/02/23 17:22:02 UTC
svn commit: r981023 [2/2] - in /websites/production/activemq/content:
broker-properties-uri.html cache/main.pageCache
configure-version-5-brokers.html jms-to-jms-bridge.html
per-destination-policies.html persistence.html slow-consumer-handling.html
Modified: websites/production/activemq/content/persistence.html
==============================================================================
--- websites/production/activemq/content/persistence.html (original)
+++ websites/production/activemq/content/persistence.html Tue Feb 23 16:22:01 2016
@@ -37,7 +37,6 @@
<script src='http://activemq.apache.org/styles/highlighter/scripts/shCore.js' type='text/javascript'></script>
<script src='http://activemq.apache.org/styles/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
<script src='http://activemq.apache.org/styles/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
- <script src='http://activemq.apache.org/styles/highlighter/scripts/shBrushPlain.js' type='text/javascript'></script>
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false;
@@ -95,7 +94,45 @@
</div></div><p>or just<br clear="none"> <strong>AMQ3.x/AMQ4.x</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">activemq
</pre>
-</div></div><p>Here is a sample XML configuration which shows how to configure the journal and the JDBC persistence.</p><p>AMQ 4.x</p><div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div><p>For more details see the <a shape="rect" href="initial-configuration.html">Initial Configuration</a> guide.</p><h2 id="Persistence-JDBCPersistencewithoutJournaling">JDBC Persistence without Journaling</h2><p>To enable JDBC persistence of JMS messages without journaling, we need to change the message broker's default persistence configuration from<br clear="none"> <strong>AMQ 4.x</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Here is a sample XML configuration which shows how to configure the journal and the JDBC persistence.</p><p>AMQ 5.x</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ 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-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <broker useJmx="true" xmlns="http://activemq.apache.org/schema/core">
+ <networkConnectors>
+ <!--
+ <networkConnector uri="multicast://default?initialReconnectDelay=100" />
+ <networkConnector uri="static://(tcp://localhost:61616)" />
+ -->
+ </networkConnectors>
+ <persistenceFactory>
+ <journalPersistenceAdapterFactory journalLogFiles="5" dataDirectory="${basedir}/target" />
+
+ <!-- To use a different dataSource, use the following syntax : -->
+ <!--
+ <journalPersistenceAdapterFactory journalLogFiles="5" dataDirectory="${basedir}/activemq-data" dataSource="#mysql-ds"/>
+ -->
+ </persistenceFactory>
+ <transportConnectors>
+ <transportConnector uri="tcp://localhost:61636" />
+ </transportConnectors>
+ </broker>
+ <!-- MySql DataSource Sample Setup -->
+ <!--
+ <bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
+ <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
+ <property name="username" value="activemq"/>
+ <property name="password" value="activemq"/>
+ <property name="poolPreparedStatements" value="true"/>
+ </bean>
+ -->
+</beans></pre>
+</div></div><p>For more details see the <a shape="rect" href="initial-configuration.html">Initial Configuration</a> guide.</p><h2 id="Persistence-JDBCPersistencewithoutJournaling">JDBC Persistence without Journaling</h2><p>To enable JDBC persistence of JMS messages without journaling, we need to change the message broker's default persistence configuration from<br clear="none"> <strong>AMQ 4.x</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><persistenceAdapter>
<journaledJDBC journalLogFiles="5" dataDirectory="../activemq-data"/>
</persistenceAdapter>
Modified: websites/production/activemq/content/slow-consumer-handling.html
==============================================================================
--- websites/production/activemq/content/slow-consumer-handling.html (original)
+++ websites/production/activemq/content/slow-consumer-handling.html Tue Feb 23 16:22:01 2016
@@ -37,7 +37,6 @@
<script src='http://activemq.apache.org/styles/highlighter/scripts/shCore.js' type='text/javascript'></script>
<script src='http://activemq.apache.org/styles/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
<script src='http://activemq.apache.org/styles/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
- <script src='http://activemq.apache.org/styles/highlighter/scripts/shBrushPlain.js' type='text/javascript'></script>
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false;
@@ -83,87 +82,70 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><p><a shape="rect" href="slow-consumers.html">Slow Consumers</a> can cause problems on non-durable topics since they can force the broker to keep old messages in RAM which once it fills up, forces the broker to slow down producers, causing the fast consumers to be slowed down. One option we could implement in the future is spooling to disk - but then spooling to disk could slow down the fast consumers too.</p>
-
-<p>Currently we have a strategy that lets you configure the maximum number of matched messages the broker will keep around for a consumer in addition to its prefetch buffer. Once this maximum is reached, as new messages come in, older messages are discarded. This allows you to keep the RAM for current messages and keep sending messages to a slow consumer but to discard old messages.</p>
-
-<h2 id="SlowConsumerHandling-PendingMessageLimitStrategy">Pending Message Limit Strategy</h2>
-
-<p>You can configure the PendingMessageLimitStrategy implementation class on the destination map so that different regions of your topic namespace can have different strategies for dealing with slow consumers. For example you may want to use this strategy for prices which are very high volume but for orders and trades which are lower volume you might not wish to discard old messages.</p>
-
-<p>The strategy calculates the maximum number of pending messages to be kept in RAM for a consumer (above its prefetch size). A value of zero means keep no messages around other than the prefetch amount. A value greater than zero will keep up to that amount of messages around, discarding the older messages as new messages come in. A value of -1 disables the discarding of messages.</p>
-
-<p>We currently have 2 different implementations of the strategy. </p>
-
-<h3 id="SlowConsumerHandling-ConstantPendingMessageLimitStrategy">ConstantPendingMessageLimitStrategy</h3>
-
-<p>This strategy uses a constant limit for all consumers (above their prefetch size). e.g.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-<constantPendingMessageLimitStrategy limit="50"/>
+<div class="wiki-content maincontent"><p><a shape="rect" href="slow-consumers.html">Slow Consumers</a> can cause problems on non-durable topics since they can force the broker to keep old messages in RAM which once it fills up, forces the broker to slow down producers, causing the fast consumers to be slowed down. One option we could implement in the future is spooling to disk - but then spooling to disk could slow down the fast consumers too.</p><p>Currently we have a strategy that lets you configure the maximum number of matched messages the broker will keep around for a consumer in addition to its prefetch buffer. Once this maximum is reached, as new messages come in, older messages are discarded. This allows you to keep the RAM for current messages and keep sending messages to a slow consumer but to discard old messages.</p><h2 id="SlowConsumerHandling-PendingMessageLimitStrategy">Pending Message Limit Strategy</h2><p>You can configure the PendingMessageLimitStrategy implementat
ion class on the destination map so that different regions of your topic namespace can have different strategies for dealing with slow consumers. For example you may want to use this strategy for prices which are very high volume but for orders and trades which are lower volume you might not wish to discard old messages.</p><p>The strategy calculates the maximum number of pending messages to be kept in RAM for a consumer (above its prefetch size). A value of zero means keep no messages around other than the prefetch amount. A value greater than zero will keep up to that amount of messages around, discarding the older messages as new messages come in. A value of -1 disables the discarding of messages.</p><p>We currently have 2 different implementations of the strategy.</p><h3 id="SlowConsumerHandling-ConstantPendingMessageLimitStrategy">ConstantPendingMessageLimitStrategy</h3><p>This strategy uses a constant limit for all consumers (above their prefetch size). e.g.</p><div class="cod
e panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><constantPendingMessageLimitStrategy limit="50"/>
</pre>
-</div></div>
-
-<h3 id="SlowConsumerHandling-PrefetchRatePendingMessageLimitStrategy">PrefetchRatePendingMessageLimitStrategy</h3>
-
-<p>This strategy calculates the maximum number of pending messages using a multiplier of the consumers prefetch size. So you could for example keep around 2.5 times the prefetch count for each consumer.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-<prefetchRatePendingMessageLimitStrategy multiplier="2.5"/>
+</div></div><h3 id="SlowConsumerHandling-PrefetchRatePendingMessageLimitStrategy">PrefetchRatePendingMessageLimitStrategy</h3><p>This strategy calculates the maximum number of pending messages using a multiplier of the consumers prefetch size. So you could for example keep around 2.5 times the prefetch count for each consumer.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><prefetchRatePendingMessageLimitStrategy multiplier="2.5"/>
</pre>
-</div></div>
-
-<h3 id="SlowConsumerHandling-UsingthePrefetchPolicytoconfigurethelimit">Using the Prefetch Policy to configure the limit</h3>
-
-<p>The JMS Client has a <a shape="rect" href="what-is-the-prefetch-limit-for.html">prefetch policy</a> you can use to configure the various prefetch limits for persistent & non persistent queues & topics. The prefetch policy also allows you to specify the maximumPendingMessageLimit on a per connection/consumer basis.</p>
-
-<p>One minor difference with configuring this value; to simplify operation with non-JMS clients such as with <a shape="rect" href="openwire.html">OpenWire</a> the value of zero is ignored; so the lowest value you can configure is 1.</p>
-
-<h3 id="SlowConsumerHandling-ConfiguringtheEvictionPolicy">Configuring the Eviction Policy</h3>
-
-<p>We have a MessageEvictionStrategy which is used to decide which message should be evicted on a slow consumer. The default implementation is</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-<oldestMessageEvictionStrategy/>
+</div></div><h3 id="SlowConsumerHandling-UsingthePrefetchPolicytoconfigurethelimit">Using the Prefetch Policy to configure the limit</h3><p>The JMS Client has a <a shape="rect" href="what-is-the-prefetch-limit-for.html">prefetch policy</a> you can use to configure the various prefetch limits for persistent & non persistent queues & topics. The prefetch policy also allows you to specify the maximumPendingMessageLimit on a per connection/consumer basis.</p><p>One minor difference with configuring this value; to simplify operation with non-JMS clients such as with <a shape="rect" href="openwire.html">OpenWire</a> the value of zero is ignored; so the lowest value you can configure is 1.</p><h3 id="SlowConsumerHandling-ConfiguringtheEvictionPolicy">Configuring the Eviction Policy</h3><p>We have a MessageEvictionStrategy which is used to decide which message should be evicted on a slow consumer. The default implementation is</p><div class="code panel pdl" style="border-width: 1px;
"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><oldestMessageEvictionStrategy/>
</pre>
-</div></div>
-
-<p>But you can write your own to use some application specific way of choosing. e.g. if you are sending market data price updates, you may wish to find an older price value, which might not be the oldest message. The implementation of this eviction strategy could be set (since version 5.6) using</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-<uniquePropertyMessageEvictionStrategy propertyName="STOCK" />
+</div></div><p>But you can write your own to use some application specific way of choosing. e.g. if you are sending market data price updates, you may wish to find an older price value, which might not be the oldest message. The implementation of this eviction strategy could be set (since version 5.6) using</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><uniquePropertyMessageEvictionStrategy propertyName="STOCK" />
</pre>
-</div></div>
-
-<p>where <code>propertyName</code> is the JMS message property that specifies the price.</p>
-
-<p>Another option could be to use the oldest message with the lowest priority message - so if you have some high priority messages, evict the lower priority messages first even if they are newer.</p>
-
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-<oldestMessageWithLowestPriorityEvictionStrategy/>
+</div></div><p>where <code>propertyName</code> is the JMS message property that specifies the price.</p><p>Another option could be to use the oldest message with the lowest priority message - so if you have some high priority messages, evict the lower priority messages first even if they are newer.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><oldestMessageWithLowestPriorityEvictionStrategy/>
</pre>
-</div></div>
-
-<h2 id="SlowConsumerHandling-Example">Example</h2>
-
-<p>The following example shows an ActiveMQ broker configuration file. Notice that for topics in the <strong>PRICES.></strong> wildcard range the <strong>pendingMessageLimitStrategy</strong> property is set to only keep around 10 messages for each consumer above their prefetch buffer size.</p>
-
-<div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>
-
-<h2 id="SlowConsumerHandling-Usagetips">Usage tips</h2>
-
-<p>It is advisable that if you know a particular consumer is going to be slow then set its prefetch size to something smaller than the fast consumers. e.g. if you know a particular box is quite slow and you have very high message rates and you have some very fast consumers; you might want to enable this feature and set the prefetch on the slow boxes to a little lower than on the fast boxes.</p>
-
-<h3 id="SlowConsumerHandling-Monitoringthestatusofslowconsumers">Monitoring the status of slow consumers</h3>
-
-<p>You can also use a <a shape="rect" href="jmx.html">JMX</a> Console to view the statistics of the active subscriptions. This allows you to view the following statistics on a TopicSubscriptionViewMBean</p>
-
-<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Statistic</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Meaning</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>discarded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The count of how many messages have been discarded during the lifetime of the subscription due to it being a slow consumer</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>matched</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The current number of messages matched and to be dispatched to the subscription as soon as some capacity is available in the prefetch buffer. So a non-zero value implies that the prefetch buffer is full for this subscription</p></td></tr></tbody></table></div></div>
+</div></div><h2 id="SlowConsumerHandling-Example">Example</h2><p>The following example shows an ActiveMQ broker configuration file. Notice that for topics in the <strong>PRICES.></strong> wildcard range the <strong>pendingMessageLimitStrategy</strong> property is set to only keep around 10 messages for each consumer above their prefetch buffer size.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ 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-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <broker persistent="false" brokerName="${brokername}" xmlns="http://activemq.apache.org/schema/core">
+ <!-- lets define the dispatch policy -->
+ <destinationPolicy>
+ <policyMap>
+ <policyEntries>
+ <policyEntry topic="FOO.>">
+ <dispatchPolicy>
+ <roundRobinDispatchPolicy />
+ </dispatchPolicy>
+ <subscriptionRecoveryPolicy>
+ <lastImageSubscriptionRecoveryPolicy />
+ </subscriptionRecoveryPolicy>
+ </policyEntry>
+ <policyEntry topic="ORDERS.>">
+ <dispatchPolicy>
+ <strictOrderDispatchPolicy />
+ </dispatchPolicy>
+ <!-- 1 minutes worth -->
+ <subscriptionRecoveryPolicy>
+ <timedSubscriptionRecoveryPolicy recoverDuration="60000" />
+ </subscriptionRecoveryPolicy>
+ </policyEntry>
+ <policyEntry topic="PRICES.>">
+ <!-- lets force old messages to be discarded for slow consumers -->
+ <pendingMessageLimitStrategy>
+ <constantPendingMessageLimitStrategy limit="10"/>
+ </pendingMessageLimitStrategy>
+ <!-- 10 seconds worth -->
+ <subscriptionRecoveryPolicy>
+ <timedSubscriptionRecoveryPolicy recoverDuration="10000" />
+ </subscriptionRecoveryPolicy>
+
+ </policyEntry>
+ <policyEntry tempTopic="true" advisoryForConsumed="true" />
+ <policyEntry tempQueue="true" advisoryForConsumed="true" />
+ </policyEntries>
+ </policyMap>
+ </destinationPolicy>
+ </broker>
+</beans></pre>
+</div></div><h2 id="SlowConsumerHandling-Usagetips">Usage tips</h2><p>It is advisable that if you know a particular consumer is going to be slow then set its prefetch size to something smaller than the fast consumers. e.g. if you know a particular box is quite slow and you have very high message rates and you have some very fast consumers; you might want to enable this feature and set the prefetch on the slow boxes to a little lower than on the fast boxes.</p><h3 id="SlowConsumerHandling-Monitoringthestatusofslowconsumers">Monitoring the status of slow consumers</h3><p>You can also use a <a shape="rect" href="jmx.html">JMX</a> Console to view the statistics of the active subscriptions. This allows you to view the following statistics on a TopicSubscriptionViewMBean</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Statistic</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Meaning</p></th></tr><tr><td c
olspan="1" rowspan="1" class="confluenceTd"><p>discarded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The count of how many messages have been discarded during the lifetime of the subscription due to it being a slow consumer</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>matched</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The current number of messages matched and to be dispatched to the subscription as soon as some capacity is available in the prefetch buffer. So a non-zero value implies that the prefetch buffer is full for this subscription</p></td></tr></tbody></table></div></div>
</td>
<td valign="top">
<div class="navigation">