blob: 3f7e284a935c7e4c05aae4d130759bcf72edbbec [file] [log] [blame]
<div class="wiki-content maincontent"><p><link><page ri:content-title="how do durable queues and topics work"></page><link-body>Durable topic subscribers</link-body></link> 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 <link><page ri:content-title="JMX"></page><link-body>JConsole</link-body></link> or <link><page ri:content-title="Web Console"></page></link>, 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>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 <link><page ri:content-title="Per Destination Policies"></page><link-body>destination policy</link-body></link>. For example, the following entry</p>
<structured-macro ac:macro-id="557bd2f0-c204-4fa3-909e-97e2891d3442" ac:name="code" ac:schema-version="1"><plain-text-body>&lt;policyEntry topic="&gt;" expireMessagesPeriod="300000"/&gt;</plain-text-body></structured-macro>
<p>will configure the broker to check for expired messages every 5 minutes.</p>
<h3>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>
<table><tbody><tr><th colspan="1" rowspan="1"><p>property</p></th><th colspan="1" rowspan="1"><p>default</p></th><th colspan="1" rowspan="1"><p>description</p></th></tr><tr><td colspan="1" rowspan="1"><p>offlineDurableSubscriberTimeout</p></td><td colspan="1" rowspan="1"><p>-1</p></td><td colspan="1" rowspan="1"><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"><p>offlineDurableSubscriberTaskSchedule</p></td><td colspan="1" rowspan="1"><p>300000</p></td><td colspan="1" rowspan="1"><p>How often we check (in milliseconds)</p></td></tr></tbody></table>
<p>An example configuration could look like</p>
<structured-macro ac:macro-id="11fbff41-33b8-4d9e-b8f7-3dcd3a3c8aae" ac:name="code" ac:schema-version="1"><plain-text-body>&lt;broker name="localhost" offlineDurableSubscriberTimeout="86400000" offlineDurableSubscriberTaskSchedule="3600000"&gt;</plain-text-body></structured-macro>
<p>which means that we check every hour and remove subscriber that has been offline for a day.</p></div>