activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torsten Mielke (Confluence)" <>
Subject [CONF] Apache ActiveMQ > Message Cursors
Date Tue, 26 Nov 2013 13:12:01 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=ACTIVEMQ&amp;forWysiwyg=true"
<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="">Message
    <h4>Page <b>edited</b> by             <a href="">Torsten
        <div id="versionComment">
        added to storeCursor and storeDurableSubscriberCursor to list of valid cursor types
in broker config.<br />
                         <h4>Changes (2)</h4>
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>Valid Subscriber
types are&amp;nbsp;*{_}vmCursor{_}* and *{_}fileCursor._*&amp;nbsp;The default is
the store based cursor. <br></td></tr>
            <tr><td class="diff-changed-lines" >Valid Durable Subscriber cursor
types <span class="diff-changed-words">are&amp;nbsp;*{_}<span class="diff-added-chars"style="background-color:
#dfd;">storeDurableSubscriberCursor{_}*, *{_}</span>vmDurableCursor{_}*</span>
and *{_}fileDurableSubscriberCursor._*&amp;nbsp;The default is the store based cursor
            <tr><td class="diff-unchanged" > <br>h4. Queues <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > &lt;/destinationPolicy&gt;
<br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" >Valid Queue cursor types are <span
class="diff-added-words"style="background-color: #dfd;">*{_}storeCursor{_}*,</span>
*{_}vmQueueCursor{_}* and *{_}fileQueueCursor._*&amp;nbsp;The default is the store based
cursor <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. See Also <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="MessageCursors-MessageCursors"></a>Message Cursors</h2>

<p>A common problem in previous versions of ActiveMQ was <a href="/confluence/display/ACTIVEMQ/My+producer+blocks"
title="My producer blocks">running out of RAM buffer</a> when using non-persistent

<p>Beginning with ActiveMQ 5.0.0, there is a new memory model that allows messages to
be paged in from storage when space is available (using Store cursors for persistent messages).</p>

<p>Releases prior to 5.0 kept references in memory for all the messages that could be
dispatched to an active Durable Topic Consumer or a Queue. While a reference itself is not
large, it does impose a limit on the maximum number of messages that can be pending delivery.</p>

<p>A typical approach for messaging systems dispatching persistent messages is to pull
them in batches from long term storage when a client is ready to consume them, using a cursor
to maintain the next to dispatch position. This is a robust and very scalable approach, but
not the most performant for cases when the consumer(s) can keep up with the producer(s) of

<p>ActiveMQ 5.0 takes a hybrid approach, allowing messages to pass from producer to
consumer directly (after the messages have been persisted), but switches back to using cursors
if the consumer(s) fall behind.</p>

<p>When Message Consumers are both active and fast - keeping up with the Message Producer(s)
- messages are stored and then passed to a dispatch queue in the broker associated with the
Consumer: <span class="image-wrap" style="display: block; text-align: center"><img
style="border: 0px solid black" /></span><br/>
If a Consumer becomes active after messages are pending from the store for it, or it's slower
than the producer, then messages are paged in to the dispatch queue from a pending cursor:
<span class="image-wrap" style="display: block; text-align: center"><img src="/confluence/download/attachments/48811/DispatchSlowConsumers.png?version=1&amp;modificationDate=1193437656000"
style="border: 0px solid black" /></span></p>

<h3><a name="MessageCursors-TypesofCursor"></a>Types of Cursor</h3>

<p>The default message cursor type in ActiveMQ 5.0&nbsp;is Store based. &nbsp;It
behaves as above. There are two&nbsp;additional&nbsp;types of cursor that could be
used: <b>VM Cursor</b> and <b>File based Cursor</b>, described below.</p>

<h4><a name="MessageCursors-VMCursor"></a>VM Cursor</h4>

<p>The VM Cursor is how ActiveMQ 4.x works: references to a message are held in memory,
and passed to the dispatch queue when needed. This can be very fast, but also has the downside
of not being able to handle very slow consumers or consumers that have been inactive for a
long time: <span class="image-wrap" style="display: block; text-align: center"><img
style="border: 0px solid black" /></span></p>

<h4><a name="MessageCursors-FilebasedCursor"></a>File based Cursor</h4>

<p>The File based Cursor is dervied from the VM Cursor. &nbsp;When memory in the
broker reaches its limit, it can page messages to temporary files on disk. This type of cursor
can be used when the message store might be relatively slow, but consumers are generally fast.
By buffering to disk, it allows the message broker to handle message bursts from producers
without resorting to paging in from slow storage: <span class="image-wrap" style="display:
block; text-align: center"><img src="/confluence/download/attachments/48811/FileCursor.png?version=1&amp;modificationDate=1193438877000"
style="border: 0px solid black" /></span></p>

<h4><a name="MessageCursors-PagingforNonPersistentMessages"></a>Paging for
Non-Persistent Messages</h4>

<p>The store based cursor also handles cursors for non-persistent messages, which are
not stored in the message store. Non-persistent messages are passed directly to the cursor,
so the store based cursor embeds a file based cursor just for these types of messages: <span
class="image-wrap" style="display: block; text-align: center"><img src="/confluence/download/attachments/48811/NonPersistentMsgs.png?version=1&amp;modificationDate=1193445319000"
style="border: 0px solid black" /></span></p>

<h3><a name="MessageCursors-ConfiguringCursors"></a>Configuring Cursors</h3>

<p>By default, Store based cursors are used, but it is possible to configure different
cursors depending on the destination.</p>

<h4><a name="MessageCursors-Topicsubscribers"></a>Topic subscribers</h4>

<p>For Topics there is a dispatch queue and pending cursor for every subscriber. &nbsp;It's
possible to configure different policies for durable subscribers and transient subscribers
- e.g:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
          &lt;policyEntry topic="org.apache.&gt;" producerFlowControl="false" memoryLimit="1mb"&gt;
              &lt;strictOrderDispatchPolicy /&gt;
              &lt;individualDeadLetterStrategy  topicPrefix="Test.DLQ." /&gt;
            	&lt;vmCursor /&gt;
<p>Valid Subscriber types are&nbsp;<b><em>vmCursor</em></b>
and <b><em>fileCursor.</em></b>&nbsp;The default is the store
based cursor.<br/>
Valid Durable Subscriber cursor types are&nbsp;<b><em>storeDurableSubscriberCursor</em></b>,
<b><em>vmDurableCursor</em></b> and <b><em>fileDurableSubscriberCursor.</em></b>&nbsp;The
default is the store based cursor</p>

<h4><a name="MessageCursors-Queues"></a>Queues</h4>

<p>For Queues there is a single dispatch Queue and pending Queue for every destination,
so configuration is slightly different:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
          &lt;policyEntry queue="org.apache.&gt;"&gt;
              &lt;individualDeadLetterStrategy queuePrefix="Test.DLQ."/&gt;
            	&lt;vmQueueCursor /&gt;
<p>Valid Queue cursor types are <b><em>storeCursor</em></b>,
<b><em>vmQueueCursor</em></b> and <b><em>fileQueueCursor.</em></b>&nbsp;The
default is the store based cursor</p>

<h3><a name="MessageCursors-SeeAlso"></a>See Also</h3>

	<li><a href="/confluence/display/ACTIVEMQ/Producer+Flow+Control" title="Producer
Flow Control">Producer Flow Control</a></li>

        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="">Change
email notification preferences</a>
        <a href="">View
        <a href="">View

View raw message