activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Gale (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache ActiveMQ > Pluggable storage lockers
Date Wed, 14 Jan 2015 21:37:00 GMT
<html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <base href="https://cwiki.apache.org/confluence" />
        <style type="text/css">
    body, #email-content, #email-content-inner { font-family: Arial,FreeSans,Helvetica,sans-serif; }
    body, p, blockquote, pre, code, td, th, li, dt, dd { font-size: 13px; }
    small { font-size: 11px; }

    body { width:100% !important; -webkit-font-smoothing: antialiased; }

    body,
    #email-wrapper { background-color: #f0f0f0; }
    #email-wrapper-inner { padding: 20px; text-align: center; }
    #email-content-inner { background-color: #fff; border: 1px solid #bbb; color: $menuTxtColour; padding:20px; text-align:left; }
    #email-wrapper-inner > table { width: 100%; }
    #email-wrapper-inner.thin > table { margin: 0 auto; width: 50%; }
    #email-footer { padding: 0 16px 32px 16px; margin: 0; }

    .email-indent { margin: 8px 0 16px 0; }
    .email-comment { margin: 0 0 0 56px; }
    .email-comment.removed { background-color: #ffe7e7; border: 1px solid #df9898; padding: 0 8px;}

    #email-title-avatar { text-align: left; vertical-align: top; width: 48px; padding-right: 8px; }
    #email-title-flavor { margin: 0; padding: 0 0 4px 0; }
    #email-title-heading { font-size: 16px; line-height: 20px; min-height: 20px; margin: 0; padding: 0; }
    #email-title .icon { border: 0; padding: 0 5px 0 0; text-align: left; vertical-align: middle; }

    #email-actions { border-top: 1px solid #bbb; color: #505050; margin: 8px 0 0 0; padding: 0; }
    #email-actions td { padding-top: 8px; }
    #email-actions .left { max-width: 45%; text-align: left; }
    #email-actions .right { text-align: right; }
    .email-reply-divider { border-top: 1px solid #bbb; color: #505050; margin: 32px 0 8px 0; padding: 8px 0; }
    .email-section-title { border-bottom: 1px solid #bbb; margin: 8px 0; padding: 8px 0 0 0; }

    .email-metadata { color: #505050; }

    a { color: #326ca6; text-decoration: none; }
    a:hover { color: #336ca6; text-decoration: underline; }
    a:active {color: #326ca6; }

    a.email-footer-link { color: #505050; font-size: 11px; }

    .email-item-list { list-style: none; margin: 4px 0; padding-left: 0; }
    .email-item-list li { list-style: none; margin: 0; padding: 4px 0; }
    .email-list-divider { color: #505050; padding: 0 0.35em; }
    .email-operation-icon { padding-right: 5px; }

    .avatar { -ms-interpolation-mode: bicubic; border-radius: 3px;}
    .avatar-link { margin: 2px; }

    .tableview th { border-bottom: 1px solid #69C; font-weight: bold; text-align: left; }
    .tableview td { border-bottom: 1px solid #bbbbbb; text-align: left; padding: 4px 16px 4px 0; }

    .aui-message {  margin: 1em 0; padding: 8px; }
    .aui-message.info { background-color: #e0f0ff; border: 1px solid #9eb6d4; }
    .aui-message.success { background-color: #ddfade; border: 1px solid #93c49f; }
    .aui-message.error,
    .aui-message.removed { background-color: #ffe7e7; border: 1px solid #df9898; color: #000; }

    .call-to-action-table { margin: 10px 1px 1px 1px;}
    .call-to-cancel-container, .call-to-action-container { padding: 5px 20px; }
    .call-to-cancel-container { border: 1px solid #aaa; background-color: #eee; border-radius: 3px; }
    .call-to-cancel-container a.call-to-cancel-button { background-color: #eee; font-size: 14px; line-height: 1; padding: 0; margin: 0; color: #666; font-family: sans-serif;}
    .call-to-action-container { border: 1px solid #486582;  background-color: #3068A2; border-radius: 3px; padding: 4px 10px; }
    .call-to-action-container a.call-to-action-button { background-color: #3068A2; font-size: 14px; line-height: 1; padding: 0; margin: 0; color: #fff; font-weight: bold; font-family: sans-serif; }

    /** The span around the inline task checkbox image */
    .diff-inline-task-overlay {
        display: inline-block;
        text-align: center;
        height: 1.5em;
        padding: 5px 0px 1px 5px;
        margin-right: 5px;
        /** Unfortunately, the negative margin-left is stripped out in gmail */
        margin-left: -5px;
    }

            @media handheld, only screen and (max-device-width: 480px) {
        div, a, p, td, th, li, dt, dd { -webkit-text-size-adjust: auto; }
        small, small a { -webkit-text-size-adjust: 90%; }

        td[id=email-wrapper-inner] { padding: 2px !important; }
        td[id=email-content-inner] { padding: 8px !important; }
        td[id="email-wrapper-inner"][class="thin"] > table { text-align: left !important; width: 100% !important; }
        td[id=email-footer] { padding: 8px 12px !important; }
        div[class=email-indent] { margin: 8px 0px !important; }
        div[class=email-comment] { margin: 0 !important; }

        p[id=email-title-flavor] a { display: block; } /* puts the username and the action on separate lines */
        p[id=email-permalink] { padding: 4px 0 0 0 !important; }

        table[id=email-actions] td { padding-top: 0 !important; }
        table[id=email-actions] td.right { text-align: right !important; }
        table[id=email-actions] .email-list-item { display: block; margin: 1em 0 !important; word-wrap: normal !important; }
        span[class=email-list-divider] { display: none; }
    }



        </style>
    </head>
    <body style="font-family: Arial, FreeSans, Helvetica, sans-serif; font-size: 13px; width: 100%; -webkit-font-smoothing: antialiased; background-color: #f0f0f0">
        <table id="email-wrapper" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f0f0f0">
            <tbody>
                <tr valign="middle">
                    <td id="email-wrapper-inner" style="font-size: 13px; padding: 20px; text-align: center">
                        <table id="email-content" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial, FreeSans, Helvetica, sans-serif; width: 100%">
                            <tbody>
                                <tr valign="top">
                                    <td id="email-content-inner" align="left" style="font-family: Arial, FreeSans, Helvetica, sans-serif; font-size: 13px; background-color: #fff; border: 1px solid #bbb; padding: 20px; text-align: left">
                                        <table id="email-title" cellpadding="0" cellspacing="0" border="0" width="100%">
                                            <tbody>
                                                <tr>
                                                    <td id="email-title-avatar" rowspan="2" style="font-size: 13px; text-align: left; vertical-align: top; width: 48px; padding-right: 8px"> <img class="avatar" src="cid:avatar_55f1f821eca17742a7f7bb51a11fe95e" border="0" height="48" width="48" style="-ms-interpolation-mode: bicubic; border-radius: 3px" /> </td>
                                                    <td valign="top" style="font-size: 13px">
                                                        <div id="email-title-flavor" class="email-metadata" style="margin: 0; padding: 0 0 4px 0; color: #505050">
                                                            <a href="    https://cwiki.apache.org/confluence/display/~paulgale " style="color:#326ca6;text-decoration:none;; color: #326ca6; text-decoration: none">Paul Gale</a> edited the page:
                                                        </div> </td>
                                                </tr>
                                                <tr>
                                                    <td valign="top" style="font-size: 13px"> <h2 id="email-title-heading" style="font-size: 16px; line-height: 20px; min-height: 20px; margin: 0; padding: 0"> <a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/Pluggable+storage+lockers" style="color: #326ca6; text-decoration: none"> <img class="icon" src="cid:page-icon" alt="" style="border: 0; padding: 0 5px 0 0; text-align: left; vertical-align: middle" /> <strong style="font-size:16px;line-height:20px;vertical-align:top;">Pluggable storage lockers</strong> </a> </h2> </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                        <div class="email-indent" style="margin: 8px 0 16px 0">
                                            <div class="email-diff">
                                                <div id="page-diffs" class="wiki-content">
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">With <span class="diff-html-added" id="added-diff-0" style="font-size: 100%; background-color: #ddfade;">the </span>5.7.0 release <span class="diff-html-removed" id="removed-diff-0" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">, we introduced the change on locking strategies for </span><span class="diff-html-added" id="added-diff-1" style="font-size: 100%; background-color: #ddfade;">of ActiveMQ the storage locking mechanism used by a persistence adapter is pluggable. This feature only applies to brokers configured in a </span>shared storage master/slave <span class="diff-html-removed" id="removed-diff-1" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">topologies. Previously </span><span class="diff-html-added" id="added-diff-2" style="font-size: 100%; background-color: #ddfade;">topology. Prior to release 5.7.0 the </span>storage locking <span class="diff-html-added" id="added-diff-3" style="font-size: 100%; background-color: #ddfade;">mechanism </span>(and thus master election) was <span class="diff-html-removed" id="removed-diff-2" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">hard-coded directly in the particular store. So KahaDB had only the option to use shared file lock, while JDBC was using database </span><span class="diff-html-added" id="added-diff-4" style="font-size: 100%; background-color: #ddfade;">dictated by the choice of persistence adapter. With the KahaDB persistence adapter, for example, the storage locking mechanism was based on a shared file lock. Similarly, the JDBC persistence adapter used a database backed storage </span>lock.</p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">Now <span class="diff-html-removed" id="removed-diff-3" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">, </span><span class="diff-html-added" id="added-diff-5" style="font-size: 100%; background-color: #ddfade;">that </span>the <span class="diff-html-added" id="added-diff-6" style="font-size: 100%; background-color: #ddfade;">choice of </span>storage <span class="diff-html-removed" id="removed-diff-4" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">locking </span><span class="diff-html-added" id="added-diff-7" style="font-size: 100%; background-color: #ddfade;">lock </span>is <span class="diff-html-removed" id="removed-diff-5" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">separated </span><span class="diff-html-added" id="added-diff-8" style="font-size: 100%; background-color: #ddfade;">divorced </span>from <span class="diff-html-removed" id="removed-diff-6" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">the store, so you can implement your own locking strategies if necessary (or tune existing ones)</span><span class="diff-html-added" id="added-diff-9" style="font-size: 100%; background-color: #ddfade;">that of the persistence adapter one can mix and match. Storage locker pluggability is made possible because all lockers must implement the </span><a href="https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/Locker.java?hb=true" class="external-link" rel="nofollow" style="color: #326ca6; text-decoration: none"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">Locker</span></a><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> interface. This interface makes it easy to implement your own storage locker when you have special requirements</span>. Of course, every <span class="diff-html-removed" id="removed-diff-7" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">store has it's </span><span class="diff-html-added" id="added-diff-10" style="font-size: 100%; background-color: #ddfade;">persistence adapter still has its </span>own default locker <span class="diff-html-added" id="added-diff-11" style="font-size: 100%; background-color: #ddfade;">which works as before</span>.</p>
                                                    <h2 id="Pluggablestoragelockers-Lockers" class="diff-block-context">Lockers</h2>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">Every locker must implement the <a href="https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/Locker.java?hb=true" class="external-link" rel="nofollow" style="color: #326ca6; text-decoration: none"><span class="diff-html-changed" id="changed-diff-0" style="background-color: #d6f0ff;">Locker</span></a><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>interface. <span class="diff-html-removed" id="removed-diff-8" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">So there are a couple of settings you can tune for every locker</span><span class="diff-html-added" id="added-diff-12" style="font-size: 100%; background-color: #ddfade;">The locker has the following configurable parameters</span>:</p>
                                                    <div class="table-wrap diff-block-context">
                                                        <table class="confluenceTable" style="border-collapse: collapse; border: 1px solid #ddd;">
                                                            <tbody>
                                                                <tr>
                                                                    <th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; font-size: 13px"> <p style="font-size: 13px">Property Name</p> </th>
                                                                    <th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; font-size: 13px"> <p style="font-size: 13px">Default Value</p> </th>
                                                                    <th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; font-size: 13px"> <p style="font-size: 13px">Description</p> </th>
                                                                </tr>
                                                                <tr>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px"> <code style="font-size: 13px">lockAcquireSleepInterval</code> </p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">10000</p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">Delay interval in milliseconds between lock acquire attempts</p> </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px"> <code style="font-size: 13px">failIfLocked</code> </p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">false</p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">Should the start fail immediately if lock cannot be obtained</p> </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    <p class="diff-context-placeholder" style="font-size: 13px">...</p>
                                                    <p class="diff-block-target" style="font-size: 13px">Every persistence adapter (or other broker service that wants to use locks) needs to implement the <a href="https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/Lockable.java?r=1383400" class="external-link" rel="nofollow" style="color: #326ca6; text-decoration: none"><span class="diff-html-changed" id="changed-diff-1" style="background-color: #d6f0ff;">Lockable</span></a><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>interface. <span class="diff-html-removed" id="removed-diff-9" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">You can use a few settings for every persistence adapter (that supports locking)</span><span class="diff-html-added" id="added-diff-13" style="font-size: 100%; background-color: #ddfade;">This adds the following configurable parameters</span>:</p>
                                                    <div class="table-wrap diff-block-context">
                                                        <table class="confluenceTable" style="border-collapse: collapse; border: 1px solid #ddd;">
                                                            <tbody>
                                                                <tr>
                                                                    <th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; font-size: 13px"> <p style="font-size: 13px">Property Name</p> </th>
                                                                    <th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; font-size: 13px"> <p style="font-size: 13px">Default Value</p> </th>
                                                                    <th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; font-size: 13px"> <p style="font-size: 13px">Description</p> </th>
                                                                </tr>
                                                                <tr>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px"> <code style="font-size: 13px">useLock</code> </p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">true</p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">can be used to turn off locking if necessary</p> </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px"> <code style="font-size: 13px">lockKeepAlivePeriod</code> </p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">0</p> </td>
                                                                    <td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em; text-align: left; vertical-align: top;; font-size: 13px"> <p style="font-size: 13px">If bigger than 0, time period (in milliseconds) to keep lock alive</p> </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    <p class="diff-context-placeholder" style="font-size: 13px">...</p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">The Shared File Locker is the default locker for the KahaDB persistence adapter. It locks a file to ensure that only the broker holding the lock (the master) is granted access to the message store.<span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;"> </span><span class="diff-html-removed" id="removed-diff-10" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">You can configure it like this</span> </p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px"> <span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">Example</span>:</p>
                                                    <table class="diff-macro diff-block-context" style="background-color: #f0f0f0;border: 1px solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;">
                                                        <thead>
                                                            <tr>
                                                                <th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight: normal;padding: 5px;; font-size: 13px"><span class="icon macro-placeholder-icon" style="background-color: ;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB-1988229788/4109/76e0dbb30bc8580e459c201f3535d84f9283a9ac.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code" style="padding-right: 5px; vertical-align: text-bottom;" /> </span>Code Block</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-properties" style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;padding: 0; border: 1px solid #dddddd;; font-size: 13px">
                                                                    <table>
                                                                        <tbody>
                                                                            <tr>
                                                                                <td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;; font-size: 13px">language</td>
                                                                                <td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;; font-size: 13px">xml</td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table> </td>
                                                            </tr>
                                                        </tbody>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding: 10px;; font-size: 13px"> <pre style="font-size: 13px">&lt;persistenceAdapter&gt;
	&lt;kahaDB directory = &quot;target/activemq-data&quot;&gt;
		&lt;locker&gt;
			&lt;shared-file-locker lockAcquireSleepInterval=&quot;5000&quot;/&gt;
		&lt;/locker&gt;
	&lt;/kahaDB&gt;
&lt;/persistenceAdapter&gt;</pre> </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <p class="diff-block-target" style="font-size: 13px">This locker implements the <code style="font-size: 13px"><span class="diff-html-changed" id="changed-diff-2" style="background-color: #d6f0ff;">keepAlive</span></code><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>method from 5.9.0 onwards so there's no point in using <code style="font-size: 13px"><span class="diff-html-changed" id="changed-diff-3" style="background-color: #d6f0ff;">lockKeepAlivePeriod</span></code><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>settings on older versions than ActiveMQ 5.9.0. Note that as of ActiveMQ 5.9.0 the KahaDB persistence adapter can also use the Lease Database Locker (see below).</p>
                                                    <p class="diff-context-placeholder" style="font-size: 13px">...</p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">The Database Locker is the default locker for the JDBC persistence adapter. It locks a database table in a transaction to ensure that only single resource is used.<span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;"> </span><span class="diff-html-removed" id="removed-diff-11" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">You can configure it like this</span> </p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px"> <span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">Example</span>:</p>
                                                    <table class="diff-macro diff-block-context" style="background-color: #f0f0f0;border: 1px solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;">
                                                        <thead>
                                                            <tr>
                                                                <th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight: normal;padding: 5px;; font-size: 13px"><span class="icon macro-placeholder-icon" style="background-color: ;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB-1988229788/4109/76e0dbb30bc8580e459c201f3535d84f9283a9ac.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code" style="padding-right: 5px; vertical-align: text-bottom;" /> </span>Code Block</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-properties" style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;padding: 0; border: 1px solid #dddddd;; font-size: 13px">
                                                                    <table>
                                                                        <tbody>
                                                                            <tr>
                                                                                <td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;; font-size: 13px">language</td>
                                                                                <td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;; font-size: 13px">xml</td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table> </td>
                                                            </tr>
                                                        </tbody>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding: 10px;; font-size: 13px"> <pre style="font-size: 13px">&lt;persistenceAdapter&gt;
    &lt;jdbcPersistenceAdapter dataDirectory=&quot;${activemq.data}&quot; dataSource=&quot;#mysql-ds&quot; lockKeepAlivePeriod=&quot;10000&quot;&gt;
        &lt;locker&gt;
            &lt;database-locker lockAcquireSleepInterval=&quot;5000&quot;/&gt;
        &lt;/locker&gt;
    &lt;/jdbcPersistenceAdapter&gt;
&lt;/persistenceAdapter&gt;</pre> </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <p class="diff-block-target" style="font-size: 13px">The Database Locker uses its&nbsp;<code style="font-size: 13px">keepAlive</code> method to ensure the broker still holds the lock. You can set the keep alive period using the <code style="font-size: 13px">lockKeepAlivePeriod</code> property. The default period is 30000 ms. If a broker fails to acquire the lock on the database, it will retry every <code style="font-size: 13px"><span class="diff-html-changed" id="changed-diff-4" style="background-color: #d6f0ff;">lockAcquireSleepInterval</span></code><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>milliseconds.</p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">This locker opens a JDBC transaction against a database table (<code style="font-size: 13px"><span class="diff-html-changed" id="changed-diff-5" style="background-color: #d6f0ff;">activemq_lock</span></code>) that lasts as long as the broker remains alive. This locks the entire table and prevents another broker from accessing the store. In most cases this will be a fairly long running JDBC transaction which occupies resources on the database over time.</p>
                                                    <p class="diff-block-target" style="font-size: 13px">A problem with this locker can <span class="diff-html-removed" id="removed-diff-12" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">occur </span><span class="diff-html-added" id="added-diff-16" style="font-size: 100%; background-color: #ddfade;">arise </span>when the master broker crashes or loses its connection to the database <span class="diff-html-removed" id="removed-diff-13" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">. The information about </span><span class="diff-html-added" id="added-diff-17" style="font-size: 100%; background-color: #ddfade;">causing </span>the lock <span class="diff-html-removed" id="removed-diff-14" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">remains </span><span class="diff-html-added" id="added-diff-18" style="font-size: 100%; background-color: #ddfade;">to remain </span>in the database <span class="diff-html-removed" id="removed-diff-15" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">, </span>until the database responds to the half closed socket connection via a <span class="diff-html-removed" id="removed-diff-16" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">tcp </span><span class="diff-html-added" id="added-diff-19" style="font-size: 100%; background-color: #ddfade;">TCP </span>timeout. The database lock expiry requirement can prevent the slave from starting <span class="diff-html-removed" id="removed-diff-17" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">for a period</span><span class="diff-html-added" id="added-diff-20" style="font-size: 100%; background-color: #ddfade;">some time</span>. In addition, if the database supports failover, and the connection is dropped in the event of a replica failover, that JDBC transaction will be rolled back. The broker sees this as a failure<span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;"> </span><span class="diff-html-removed" id="removed-diff-18" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">and both </span><span class="diff-html-added" id="added-diff-21" style="font-size: 100%; background-color: #ddfade;">. Both </span>master and slave <span class="diff-html-added" id="added-diff-22" style="font-size: 100%; background-color: #ddfade;">brokes </span>will again compete for a lock.</p>
                                                    <p class="diff-context-placeholder" style="font-size: 13px">...</p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">The Lease Database Locker <span class="diff-html-removed" id="removed-diff-19" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">solves the master/slave problems </span><span class="diff-html-added" id="added-diff-23" style="font-size: 100%; background-color: #ddfade;">was created to solve the shortcomings </span>of the <span class="diff-html-removed" id="removed-diff-20" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">default </span>Database Locker. <span class="diff-html-removed" id="removed-diff-21" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">It </span><span class="diff-html-added" id="added-diff-24" style="font-size: 100%; background-color: #ddfade;">The Lease Database Locker </span>does not open a long running JDBC transaction<span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;"> </span><span class="diff-html-removed" id="removed-diff-22" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">but </span><span class="diff-html-added" id="added-diff-25" style="font-size: 100%; background-color: #ddfade;">. Instead it </span>lets the master broker acquire a lock that's <span class="diff-html-removed" id="removed-diff-23" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">only </span>valid for a <span class="diff-html-removed" id="removed-diff-24" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">short period</span><span class="diff-html-added" id="added-diff-26" style="font-size: 100%; background-color: #ddfade;">fixed (usually short) duration after which it expires</span>. To retain the lock the master broker must periodically extend the lock's lease <span class="diff-html-added" id="added-diff-27" style="font-size: 100%; background-color: #ddfade;">before it expires</span>. <span class="diff-html-removed" id="removed-diff-25" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">The </span><span class="diff-html-added" id="added-diff-28" style="font-size: 100%; background-color: #ddfade;">Simultaneously the </span>slave broker also checks periodically to see if the lease has expired. <span class="diff-html-removed" id="removed-diff-26" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">The lease </span><span class="diff-html-added" id="added-diff-29" style="font-size: 100%; background-color: #ddfade;">If, for whatever reason, the master broker fails to update its lease on the lock the slave will take ownership of the lock becoming the new master in the process. The leased lock </span>can survive a <span class="diff-html-removed" id="removed-diff-27" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">db </span><span class="diff-html-added" id="added-diff-30" style="font-size: 100%; background-color: #ddfade;">DB </span>replica failover.<span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;"> </span><span class="diff-html-removed" id="removed-diff-28" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">You can configure it like this</span> </p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px"> <span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">Example</span>:</p>
                                                    <table class="diff-macro diff-block-context" style="background-color: #f0f0f0;border: 1px solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;">
                                                        <thead>
                                                            <tr>
                                                                <th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight: normal;padding: 5px;; font-size: 13px"><span class="icon macro-placeholder-icon" style="background-color: ;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB-1988229788/4109/76e0dbb30bc8580e459c201f3535d84f9283a9ac.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code" style="padding-right: 5px; vertical-align: text-bottom;" /> </span>Code Block</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-properties" style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;padding: 0; border: 1px solid #dddddd;; font-size: 13px">
                                                                    <table>
                                                                        <tbody>
                                                                            <tr>
                                                                                <td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;; font-size: 13px">language</td>
                                                                                <td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align: left;; font-size: 13px">xml</td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table> </td>
                                                            </tr>
                                                        </tbody>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding: 10px;; font-size: 13px"> <pre style="font-size: 13px">&lt;persistenceAdapter&gt;
	&lt;jdbcPersistenceAdapter dataDirectory=&quot;${activemq.data}&quot; dataSource=&quot;#mysql-ds&quot; lockKeepAlivePeriod=&quot;5000&quot;&gt;
		&lt;locker&gt;
			&lt;lease-database-locker lockAcquireSleepInterval=&quot;10000&quot;/&gt;
		&lt;/locker&gt;
	&lt;/jdbcPersistenceAdapter&gt;
&lt;/persistenceAdapter&gt;</pre> </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <p class="diff-block-target" style="font-size: 13px">In order for this mechanism to work correctly, each broker in the master/slave pair must have a different <code style="font-size: 13px">brokerName</code> attribute defined on the <code style="font-size: 13px">broker</code> tag or use <span class="diff-html-added" id="added-diff-32" style="font-size: 100%; background-color: #ddfade;">the </span><span><code style="font-size: 13px"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">leaseHolderId</span></code><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> attribute</span></span><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> on </span>the&nbsp;<code style="font-size: 13px"><span style="line-height: 1.4285715;">lease-database-locker</span></code><code style="font-size: 13px"><span class="diff-html-removed" id="removed-diff-29" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">leaseHolderId</span></code><span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;"> attribute</span><span><span class="diff-html-changed" id="changed-diff-6" style="background-color: #d6f0ff;">, as it is this value that is used to reserve a lease.</span></span> </p>
                                                    <p class="diff-block-context" style="font-size: 13px">The lease based lock is acquired by blocking at startup. It is then retained for a period whose duration (in ms) is given by the <code style="font-size: 13px">lockKeepAlivePeriod</code> attribute. To retain the lock the master broker periodically extends its lease by <code style="font-size: 13px">lockAcquireSleepInterval</code> milliseconds each time. In theory, therefore, the master broker is always (<code style="font-size: 13px">lockAcquireSleepInterval</code>&nbsp;<code style="font-size: 13px">-</code> <code style="font-size: 13px">lockKeepAlivePeriod</code>) ahead of the slave broker with regard to the lease. It is imperative that <code style="font-size: 13px">lockAcquireSleepInterval &gt; lockKeepAlivePeriod</code>, to ensure the lease is always current. As of ActiveMQ 5.9.0 a warning message is logged if this condition is not met.</p>
                                                    <p class="diff-block-target" style="font-size: 13px">In the simplest case, the clocks between master and slave must be in sync for this solution to work properly. If the clocks cannot be in sync, the locker can use the system time from the database CURRENT TIME and adjust the timeouts in accordance with their local variance from the <span class="diff-html-removed" id="removed-diff-30" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">db </span><span class="diff-html-added" id="added-diff-33" style="font-size: 100%; background-color: #ddfade;">DB </span>system time. If&nbsp;<code style="font-size: 13px">maxAllowableDiffFromDBTime</code> is greater than zero the local periods will be adjusted by any delta that exceeds <code style="font-size: 13px">maxAllowableDiffFromDBTime</code>.</p>
                                                    <table class="diff-macro diff-block-target" style="background-color: #f0f0f0;border: 1px solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;">
                                                        <thead>
                                                            <tr>
                                                                <th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight: normal;padding: 5px;; font-size: 13px"><span class="icon macro-placeholder-icon" style="background-color: ;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB-1988229788/4109/76e0dbb30bc8580e459c201f3535d84f9283a9ac.1/_/images/icons/macrobrowser/dropdown/info.png" style="padding-right: 5px; vertical-align: text-bottom;" /> </span>Info</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding: 10px;; font-size: 13px"> <p style="font-size: 13px">It is important to know if the default rules your JDBC driver uses for converting <code style="font-size: 13px"><span class="diff-html-changed" id="changed-diff-7" style="background-color: #d6f0ff;">TIME</span></code><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>values are JDBC compliant. If you're using MySQL, for example, the driver's JDBC URL should contain&nbsp;<code style="font-size: 13px">useJDBCCompliantTimezoneShift=true</code> to ensure that <code style="font-size: 13px"><span class="diff-html-changed" id="changed-diff-8" style="background-color: #d6f0ff;">TIME</span></code><span class="diff-html-changed" style="background-color: #d6f0ff;"> </span>value conversion is JDBC compliant. If not the locker could report a large time difference when it compares the retrieved lease expiration time against the current system time. Consult your JDBC driver's <span class="diff-html-removed" id="removed-diff-31" style="font-size: 100%; background-color: #ffe7e7; text-decoration: line-through;">manual </span><span class="diff-html-added" id="added-diff-34" style="font-size: 100%; background-color: #ddfade;">documentation </span>for more details.</p> </td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    <p class="diff-block-context" style="font-size: 13px">As of ActiveMQ 5.9.0 the lease database locker can be used in conjunction with the KahaDB persistence adapter. However, this particular combination requires that the lease database locker element contains a <code style="font-size: 13px">&lt;statements/&gt;</code> child element. In the example below the&nbsp;<code style="font-size: 13px">lockTableName</code> is also configured, although doing so is not mandatory.</p>
                                                    <p class="diff-context-placeholder" style="font-size: 13px">...</p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px">To see the complete list of attributes and SQL statements that can be overridden see the <a href="https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/Statements.java?hb=true" class="external-link" rel="nofollow" style="color: #326ca6; text-decoration: none">Statements</a> class. <span class="diff-html-added" id="added-diff-35" style="font-size: 100%; background-color: #ddfade;">When the KahaDB persistence adapter is configured to use the </span><code style="font-size: 13px"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">lease-database-locker</span></code><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> you must configure the broker to use your own IO exception handler as neither the </span><code style="font-size: 13px"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">DefaultIOExceptionHandler</span></code><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> nor the </span><code style="font-size: 13px"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">JDBCIOExceptionHandler</span></code><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> will work correctly with this combination. See </span><a class="confluence-link unresolved" href="#" style="color: #326ca6; text-decoration: none"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">Configurable IOException Handlers</span></a><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> for details on how to write a handler.</span> </p>
                                                    <p class="diff-block-target diff-block-context" style="font-size: 13px"> <span class="diff-html-added" id="added-diff-36" style="font-size: 100%; background-color: #ddfade;">As of ActiveMQ 5.11, however, the </span><code style="font-size: 13px"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">JDBCIOExceptionHandler</span></code><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> has been deprecated. It has been replaced by the </span><code style="font-size: 13px"><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">org.apache.activemq.util.LeaseLockerIOExceptionHandler</span></code><span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;"> which will work with any persistence adapter that supports pluggable storage lockers.</span> </p>
                                                    <p class="diff-block-context" style="font-size: 13px">&nbsp;</p>
                                                    <p class="diff-block-context" style="font-size: 13px">&nbsp;</p>
                                                </div>
                                            </div>
                                        </div>
                                        <table id="email-actions" class="email-metadata" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-top: 1px solid #bbb; color: #505050; margin: 8px 0 0 0; padding: 0; color: #505050">
                                            <tbody>
                                                <tr>
                                                    <td class="left" valign="top" style="font-size: 13px; padding-top: 8px; max-width: 45%; text-align: left"> <span class="email-list-item"><a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/Pluggable+storage+lockers" style="color: #326ca6; text-decoration: none">View Online</a> </span> <span class="email-list-divider" style="color: #505050; padding: 0 0.350em">&middot;</span> <span class="email-list-item"><a href="https://cwiki.apache.org/confluence/plugins/likes/like.action?contentId=30150882" style="color: #326ca6; text-decoration: none">Like</a> </span> <span class="email-list-divider" style="color: #505050; padding: 0 0.350em">&middot;</span> <span class="email-list-item"><a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30150882&amp;revisedVersion=18&amp;originalVersion=17" style="color: #326ca6; text-decoration: none">View Changes</a> </span> </td>
                                                    <td class="right" width="50%" valign="top" style="font-size: 13px; padding-top: 8px; text-align: right"> <span class="email-list-item"><a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=ACTIVEMQ" style="color: #326ca6; text-decoration: none">Stop watching space</a> </span> <span class="email-list-divider" style="color: #505050; padding: 0 0.350em">&middot;</span> <span class="email-list-item"><a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action" style="color: #326ca6; text-decoration: none">Manage Notifications</a> </span> </td>
                                                </tr>
                                            </tbody>
                                        </table> </td>
                                </tr>
                            </tbody>
                        </table> </td>
                </tr>
                <tr>
                    <td id="email-footer" align="center" style="font-size: 13px; padding: 0 16px 32px 16px; margin: 0"> <small style="font-size: 11px"> This message was sent by <a class="email-footer-link" style="color:#505050;font-size:11px;text-decoration:none;; color: #326ca6; text-decoration: none; color: #505050; font-size: 11px" href="http://www.atlassian.com/software/confluence">Atlassian Confluence</a> 5.0.3, <a class="email-footer-link" style="color:#505050;font-size:11px;text-decoration:none;; color: #326ca6; text-decoration: none; color: #505050; font-size: 11px" href="http://www.atlassian.com/software/confluence/overview/team-collaboration-software?utm_source=email-footer">Team Collaboration Software</a> </small> </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
Mime
View raw message