Hello Andrew,

Unfortunately, you cannot by server side configuration decide whether messages are kept in memory or written on disk. This is done by the producer, who decides if messages are persistent (this is the default) or not.

Persistent messages are always written to disk in order to ensure that if a failure on the broker happens, no messages are lost. On the contrary, non-persistent messages are kept in memory until the memory limit is reached. When memory limit is reached, messages are paged to disk until tempUsage is reached (after what producers are blocked until the limit goes down).

According to the wiki page on http://activemq.apache.org/producer-flow-control.html , there seems to be a way to ensure messages are always kept in memory (I have not tested it though). Here is what the documentation says:

-----------------

Note that, since the introduction of the new file cursor in ActiveMQ 5.x, non-persisted messages are shunted into the temporary file store to reduce the amount of memory used for non-persistent messaging. As a result, you may find that a queue's memoryLimit is never reached, as the cursor doesn't use very much memory. If you really do want to keep all your non-persistent messages in memory, and stop producers when the limit is reached, you should configure the <vmQueueCursor>.

                <policyEntry queue=">"  producerFlowControl="true"  
memoryLimit="1mb">
                  <pendingQueuePolicy>
                    <vmQueueCursor/>
                  </pendingQueuePolicy>
                </policyEntry>

The fragment above will ensure that all non-persistent queue messages are kept in memory, with each queue having a limit of 1Mb.

--------------------

Hope it help.

Cheers,
Reynald


On 08/09/2010 02:35 PM, iDemmel wrote:
Hello

I need the broker to hold me 50,000 messages in a queue before starting to
write to my HDD.
Being new to ActiveMQ, I tried changing the config a bit. I tried to change
the following config(I couldn't find something for amount of messages, so I
just took memory), with no success:
1)<policyEntry queue=">" producerFlowControl="true" memoryLimit="128mb">
2)<systemUsage>
             <systemUsage>
                 <memoryUsage><memoryUsage limit="256 mb"/></memoryUsage>
                 <storeUsage><storeUsage limit="1 gb"
name="foo"/></storeUsage>
                 <tempUsage><tempUsage limit="100 mb"/></tempUsage>
             </systemUsage>
      </systemUsage>

Whatever I do with these values, once I start producing (a lot), my HDD goes
crazy, even from the start.
I'm just a beginner, and I'm probably missing something basic but please
help me out.

To summarize my questions:
1) How do I keep the queue in RAM only until it reaches 50k entries ?
2) Is it possible to configure the above with an amount of messages instead
of memory?

Thank you for your time

Andrew

Reply via email to