qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Qpid > Qpid java Broker Transaction Timeouts
Date Wed, 09 Mar 2011 17:39:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2036/9/21/_/styles/combined.css?spaceKey=qpid&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/qpid/Qpid+java+Broker+Transaction+Timeouts">Qpid
java Broker Transaction Timeouts</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~andrew.kennedy">Andrew
Kennedy</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="QpidjavaBrokerTransactionTimeouts-TransactionTimeoutsUserGuide"></a>Transaction
Timeouts User Guide</h1>

<h2><a name="QpidjavaBrokerTransactionTimeouts-Introduction"></a>Introduction</h2>

<p>Qpid 2.6.0.6 includes a new feature to allow deployers to configure transaction timeout
thresholds, and the associated actions to perform on crossing of the specified threshold.</p>

<p>The transaction timeout mechanism is used to control broker resources when clients
producing messages using transactional sessions hang or otherwise become unresponsive. </p>

<p>Users can choose to configure a Warn threshold, after which the identified transaction
should be logged as a 'WARN' level alert as well as (importantly) a Close threshold after
which the transaction and the connection it applies to will be closed.</p>

<p>This feature is particularly useful in environments where the owner of the broker
does not have full control over the implementation of clients, such as in a shared services
deployment.</p>

<p>The following section provide more details on this feature and its use.</p>

<h3><a name="QpidjavaBrokerTransactionTimeouts-Purpose"></a>Purpose </h3>

<p>This feature has been introduced to address the scenario where an open transaction
can include an open transaction on the BDB store. This can have undesirable consequences,
preventing the BDB store cleaning thread from rolling forward data efficiently and can result
in a rapidly growing store bound only by available disk space.</p>

<h3><a name="QpidjavaBrokerTransactionTimeouts-Scope"></a>Scope</h3>

<p>Note that only <tt>MessageProducer</tt> clients will be affected by a
transaction timeout, since transaction lifespan on a consumer only spans the execution of
the commit and there is no scope for a long-lived transaction to arise.</p>

<p>It is also important to note that the transaction timeout mechanism is purely a JMS
transaction timeout, and unrelated to any other timeouts in the Qpid client library and will
have no impact on any RDBMS your application may utilise.</p>

<h3><a name="QpidjavaBrokerTransactionTimeouts-Effect"></a>Effect</h3>

<p>Full details of configuration options are provided in the sections that follow. This
section gives a brief overview of what the Transaction Timeout feature can do.</p>

<h4><a name="QpidjavaBrokerTransactionTimeouts-BrokerLoggingandConnectionClose"></a>Broker
Logging and Connection Close</h4>

<p>When the 'openWarn' or 'idleWarn' specified threshold is exceeded, the broker will
log a 'WARN' level alert with details of the connection and channel on which the threshold
has been exceeded, along with the age of the transaction.</p>

<p>When the 'openClose' or 'idelClose' specified threshold value is exceeded, the broker
will throw an exception back to the client on its exception listener, log the action and then
close the connection. </p>

<p>The example broker log output shown below is where the Warn threshold specified is
lower than the Close threshold and the broker therefore logs the idle transaction 3 times
before the close threshold is triggered and the connection closed out.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:1(guest@anonymous(29494388)/test)/ch:2]
CHN-1008 : Idle Transaction : 13,116 ms
WARN [apache.qpid.server.AMQChannel] IDLE TRANSACTION ALERT [con:1(guest@anonymous(29494388)/test)/ch:2]
 13116 ms
INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:1(guest@anonymous(29494388)/test)/ch:2]
CHN-1008 : Idle Transaction : 14,116 ms
WARN [apache.qpid.server.AMQChannel] IDLE TRANSACTION ALERT [con:1(guest@anonymous(29494388)/test)/ch:2]
 14116 ms
INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:1(guest@anonymous(29494388)/test)/ch:2]
CHN-1008 : Idle Transaction : 15,118 ms
WARN [apache.qpid.server.AMQChannel] IDLE TRANSACTION ALERT [con:1(guest@anonymous(29494388)/test)/ch:2]
 15118 ms
INFO [qpid.server.protocol.AMQProtocolSession] Closing connection due to: org.apache.qpid.AMQConnectionException:
 Idle transaction timed out [error code 506: resource error]
INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:1(guest@anonymous(29494388)/test)/ch:2]
CHN-1003 : Close
</pre>
</div></div>

<p>The second example broker log output shown below illustrates the same mechanism operating
on an Open transaction.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:2(guest@anonymous(27925944)/test)/ch:2]
CHN-1007 : Open Transaction : 12,406 ms
WARN [apache.qpid.server.AMQChannel] OPEN TRANSACTION ALERT [con:2(guest@anonymous(27925944)/test)/ch:2]
 12406 ms
INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:2(guest@anonymous(27925944)/test)/ch:2]
CHN-1007 : Open Transaction : 13,406 ms
WARN [apache.qpid.server.AMQChannel] OPEN TRANSACTION ALERT [con:2(guest@anonymous(27925944)/test)/ch:2]
 13406 ms
INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:2(guest@anonymous(27925944)/test)/ch:2]
CHN-1007 : Open Transaction : 14,406 ms
WARN [apache.qpid.server.AMQChannel] OPEN TRANSACTION ALERT [con:2(guest@anonymous(27925944)/test)/ch:2]
 14406 ms
INFO [qpid.server.protocol.AMQProtocolSession] Closing connection due to: org.apache.qpid.AMQConnectionException:
 Open transaction timed out [error code 506: resource error]
INFO [qpid.message] MESSAGE [Queue-housekeeping-test][con:2(guest@anonymous(27925944)/test)/ch:2]
CHN-1003 : Close
</pre>
</div></div>

<h4><a name="QpidjavaBrokerTransactionTimeouts-ClientSideEffect"></a>Client
Side Effect</h4>

<p>After a Close threshold has been exceeded, the trigger client will receive this exception
on its exception listener, prior to being disconnected:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>org.apache.qpid.AMQConnectionClosedException: Error: Idle transaction timed out
[error code 506: resource error] [error code 506: resource error]
</pre>
</div></div>

<p>Any later attempt to use the connection will result in this exception being thrown:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>Producer: Caught an Exception: javax.jms.IllegalStateException: Object org.apache.qpid.client.AMQSession_0_8@129b0e1
has been closed
javax.jms.IllegalStateException: Object org.apache.qpid.client.AMQSession_0_8@129b0e1 has
been closed
        at org.apache.qpid.client.Closeable.checkNotClosed(Closeable.java:70)
        at org.apache.qpid.client.AMQSession.checkNotClosed(AMQSession.java:555)
        at org.apache.qpid.client.AMQSession.createBytesMessage(AMQSession.java:573)
        at org.apache.qpid.test.unit.transacted.TransactedProducer.runTest(TransactedProducer.java:138)
        at org.apache.qpid.test.unit.transacted.TransactedProducer.main(TransactedProducer.java:86)
</pre>
</div></div>

<p>Thus <b>clients must be able to handle this case successfully, reconnecting
where required and registering an exception listener on all connections</b>. This is
critical, and must be communicated to client applications by any broker owner switching on
transaction timeouts.</p>

<h3><a name="QpidjavaBrokerTransactionTimeouts-Configuration"></a>Configuration</h3>

<h4><a name="QpidjavaBrokerTransactionTimeouts-Overview"></a>Overview</h4>

<p>Transaction timeouts are configurable separately on each defined virtual host, using
the <tt>virtualhosts.xml</tt> file. </p>

<p>We would recommend that only warnings are configured at first, which should allow
broker administrators to obtain an idea of the distribution of transaction lengths on their
systems, and configure production settings appropriately for both warning and closure. Ideally
establishing thresholds should be achieved in a representative UAT environment, with clients
and broker running, prior to any production deployment.</p>

<p>It is impossible to give suggested values, due to the large variation in usage depending
on the applications using a broker. However, clearly transactions should not span the expected
lifetime of any client application as this would indicate a hung client.</p>

<p>When configuring warning and closure timeouts, it should be noted that these only
apply to message producers that are connected to the broker, but that a timeout will cause
the connection to be closed - this disconnecting all producers and consumers created on that
connection.</p>

<p>This should not be an issue for environments using Mule or Spring, where connection
factories can be configured appropriately to manage a single <tt>MessageProducer</tt>
object per JMS Session and Connection. Clients that use the JMS API directly should be aware
that sessions managing both consumers and producers, or multiple producers, will be affected
by a single producer hanging or leaving a transaction idle or open, and closed, and must take
appropriate action to handle that scenario.</p>

<h4><a name="QpidjavaBrokerTransactionTimeouts-Virtualhosts.xmlEntries"></a>Virtualhosts.xml
Entries</h4>

<p>The JMS transaction timeouts are configured on each virtual host defined in the XML
configuration files. </p>

<p>The default values for each of the parameters is <em>0</em>, indicating
that that particular check is disabled. </p>

<p>Any or all of the parameters can be set, using the desired value in milliseconds,
and will be checked each time the housekeeping process runs, usually set to run every 30 seconds
in standard configuration. The meaning of each property is as follows:</p>

<ul>
	<li><b>openWarn</b> - the time a transaction can be open for (with activity
occurring on it) after which a warning alert will be issued.</li>
	<li><b>openClose</b> - the time a transaction can be open for before the
connection it is on is closed.</li>
	<li><b>idleWarn</b> - the time a transaction can be idle for (with no activity
occurring on it) after which a warning alert will be issued.</li>
	<li><b>idleClose</b> - the time a transaction can be idle for before the
connection it is on is closed.</li>
</ul>


<p>The virtualhosts configuration is shown below, and must occur inside the <tt>//virtualhosts/virtualhost/name/</tt>
elements:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>virtualhosts.xml</b></div><div
class="codeContent panelContent">
<pre class="code-java">
&lt;transactionTimeout&gt;
    &lt;openWarn&gt;10000&lt;/openWarn&gt;
    &lt;openClose&gt;20000&lt;/openClose&gt;
    &lt;idleWarn&gt;5000&lt;/idleWarn&gt;
    &lt;idleClose&gt;15000&lt;/idleClose&gt;
&lt;/transactionTimeout&gt;
</pre>
</div></div>
    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://cwiki.apache.org/confluence/display/qpid/Qpid+java+Broker+Transaction+Timeouts">View
Online</a>
              |
       <a href="https://cwiki.apache.org/confluence/display/qpid/Qpid+java+Broker+Transaction+Timeouts?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message