blob: f02f5e56001d3959ec34259188558177f7a6a129 [file] [log] [blame]
<div class="wiki-content maincontent"><p><a shape="rect" href="how-do-durable-queues-and-topics-work.html">Durable topic subscribers</a> that are offline for a long period of time are usually not desired in the system. The reason for that is that broker needs to keep all the messages sent to those topics for the said subscribers. And this message piling can over time exhaust broker store limits for example and lead to the overall slowdown of the system.</p>
<p>You can always manually unsubscribe inactive durable subscriber using management tools like <a shape="rect" href="jmx.html">JConsole</a> or <a shape="rect" href="web-console.html">Web Console</a>, but clearly there's more that can be done to help manage systems that use durable subscribers (perhaps coming from environments that they don't control) </p>
<p>Staring with version 5.6 we introduced a few improvements in this area.</p>
<h3 id="ManageDurableSubscribers-Expiringmessages">Expiring messages</h3>
<p>Some applications send message with specified time to live. If those messages are kept on the broker for the offline durable subscriber we need to remove them when they reach their expiry time. Just as we do with queues, now we check for those messages every 30 seconds by default, which can be tuned with the appropriate <a shape="rect" href="per-destination-policies.html">destination policy</a>. For example, the following entry</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;">&lt;policyEntry topic="&gt;" expireMessagesPeriod="300000"/&gt;</pre>
</div></div>
<p>will configure the broker to check for expired messages every 5 minutes.</p>
<h3 id="ManageDurableSubscribers-Removinginactivesubscribers">Removing inactive subscribers</h3>
<p>The other thing we can do is to automatically unsubscribe durable subscribers that are not active for some period of time. For that purpose we introduced two new broker properties:</p>
<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>property</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>default</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>offlineDurableSubscriberTimeout</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>-1</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Amount of time (in milliseconds) after which we remove inactive durable subs. Default -1, means don't remove them</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>offlineDurableSubscriberTaskSchedule</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>300000</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>How often we check (in milliseconds)</p></td></tr></tbody></table></div>
<p>An example configuration could look like</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;">&lt;broker name="localhost" offlineDurableSubscriberTimeout="86400000" offlineDurableSubscriberTaskSchedule="3600000"&gt;</pre>
</div></div>
<p>which means that we check every hour and remove subscriber that has been offline for a day.</p></div>