You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Roberto Cappa <ca...@gmail.com> on 2010/12/11 12:52:25 UTC
Persistence without spooling, memory limit, eviction policies
Hi,
I'm evaluating the possibility to use ActiveMQ in my project to manage a
persistent queue. I've done some tests, but I've encountered some issues.
These are my requirements:
- All queues in my broker must be persistent, because I cannot loose pending
messages if the system goes down. This is the code, and it is ok, it works:
BrokerService jmsBroker = new BrokerService();
jmsBroker.setPersistent(true);
- I've to set a memory (or messages number) limit, in order to prevent too
high memory usage by the queue on my VM. This is the code:
List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
PolicyEntry conf = new PolicyEntry();
conf.setMemoryLimit(5000000);
conf.setQueue("myQueue");
entries.add(conf);
policyMap.setPolicyEntries(entries);
jmsBroker.setDestinationPolicy(policyMap);
This is the first problem: if setPersistent(false) it works, but if
setPersistent(true) the broker ignores the memory limit, when the memory is
full starts spooling to disk. It is an undesired behavior, persistence and
spooling are two logical separate concepts. Is there a way to set a memory
limit and persistence without enabling spooling?
- When the memory limit is reached, by default the producer is blocked (if
persistence is false) or slowed (if persistence is true). There are two
undesired behaviors, my producer cannot be blocked or slowed by the queue (I
think it is a typical asynchronous scenario). If the queue is full, I can
choose two options, both valid for my requirements:
- Throwing an exception in producer code, so I can take actions in case
of full queue.
- Discard oldest messages from the queue, accepting the new ones from
the producer, without blocking.
For the first scenario, I haven't found any suitable configuration on
ActiveMQ.
For the secondo scenario, I've tryed with this code:
OldestMessageEvictionStrategy strategy = new
OldestMessageEvictionStrategy();
conf.setMessageEvictionStrategy(strategy);
...
But it seems to be completely ignored. Any idea?
Thanks.
Re: Persistence without spooling, memory limit, eviction policies
Posted by Reynald Borer <re...@gmail.com>.
Are you using transactions to consume your messages?
Have you defined a storeUsage limit? If so as the data is stored in
chunks of data (default to 32mb) and your store limit is lower than
this value, the persistence adapter won't be able to cleanup a chunk
full of consumed message so consumers will remain blocked. Check those
system limits through the web console or JMX.
On Wed, Dec 15, 2010 at 12:20 PM, Roberto Cappa <ca...@gmail.com> wrote:
> Hi, any idea? Thanks
>
> 2010/12/11 Roberto Cappa <ca...@gmail.com>
>
>> Sorry, the producer isn't blocked, but it continues to throw exception like
>> the queue was full.
>>
>> 2010/12/11 Roberto Cappa <ca...@gmail.com>
>>
>> Thanks, It seems to work but...
>>> When the maximum of memory is reached the producer throws an exception
>>> (ok)... But when messages are consumed, the producer remains blocked because
>>> the memory isn't deallocated, so the producer remains blocked forever (also
>>> if the queue became empty!). Is there a way to force queue resizing?
>>>
>>> Thanks.
>>>
>>> 2010/12/11 Stan Lewis <sl...@fusesource.com>
>>>
>>> You probably need to turn off producer flow control and then also
>>>> enable sendFailIfNoSpace or sendFailIfNoSpaceAfterTimeout, there's a
>>>> bunch of information here:
>>>>
>>>> http://activemq.apache.org/producer-flow-control.html
>>>>
>>>> On Sat, Dec 11, 2010 at 6:52 AM, Roberto Cappa <ca...@gmail.com>
>>>> wrote:
>>>> > Hi,
>>>> >
>>>> > I'm evaluating the possibility to use ActiveMQ in my project to manage
>>>> a
>>>> > persistent queue. I've done some tests, but I've encountered some
>>>> issues.
>>>> > These are my requirements:
>>>> >
>>>> > - All queues in my broker must be persistent, because I cannot loose
>>>> pending
>>>> > messages if the system goes down. This is the code, and it is ok, it
>>>> works:
>>>> >
>>>> > BrokerService jmsBroker = new BrokerService();
>>>> > jmsBroker.setPersistent(true);
>>>> >
>>>> > - I've to set a memory (or messages number) limit, in order to prevent
>>>> too
>>>> > high memory usage by the queue on my VM. This is the code:
>>>> >
>>>> > List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
>>>> > PolicyEntry conf = new PolicyEntry();
>>>> > conf.setMemoryLimit(5000000);
>>>> > conf.setQueue("myQueue");
>>>> > entries.add(conf);
>>>> > policyMap.setPolicyEntries(entries);
>>>> > jmsBroker.setDestinationPolicy(policyMap);
>>>> >
>>>> > This is the first problem: if setPersistent(false) it works, but if
>>>> > setPersistent(true) the broker ignores the memory limit, when the
>>>> memory is
>>>> > full starts spooling to disk. It is an undesired behavior, persistence
>>>> and
>>>> > spooling are two logical separate concepts. Is there a way to set a
>>>> memory
>>>> > limit and persistence without enabling spooling?
>>>> >
>>>> > - When the memory limit is reached, by default the producer is blocked
>>>> (if
>>>> > persistence is false) or slowed (if persistence is true). There are two
>>>> > undesired behaviors, my producer cannot be blocked or slowed by the
>>>> queue (I
>>>> > think it is a typical asynchronous scenario). If the queue is full, I
>>>> can
>>>> > choose two options, both valid for my requirements:
>>>> >
>>>> > - Throwing an exception in producer code, so I can take actions in
>>>> case
>>>> > of full queue.
>>>> > - Discard oldest messages from the queue, accepting the new ones
>>>> from
>>>> > the producer, without blocking.
>>>> >
>>>> > For the first scenario, I haven't found any suitable configuration on
>>>> > ActiveMQ.
>>>> > For the secondo scenario, I've tryed with this code:
>>>> >
>>>> > OldestMessageEvictionStrategy strategy = new
>>>> > OldestMessageEvictionStrategy();
>>>> > conf.setMessageEvictionStrategy(strategy);
>>>> > ...
>>>> >
>>>> > But it seems to be completely ignored. Any idea?
>>>> >
>>>> >
>>>> > Thanks.
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Stan Lewis
>>>> FuseSource
>>>> Email: slewis@fusesource.com
>>>> Web: http://fusesource.com
>>>> Twitter: gashcrumb
>>>>
>>>
>>>
>>
>
Re: Persistence without spooling, memory limit, eviction policies
Posted by Roberto Cappa <ca...@gmail.com>.
Hi, any idea? Thanks
2010/12/11 Roberto Cappa <ca...@gmail.com>
> Sorry, the producer isn't blocked, but it continues to throw exception like
> the queue was full.
>
> 2010/12/11 Roberto Cappa <ca...@gmail.com>
>
> Thanks, It seems to work but...
>> When the maximum of memory is reached the producer throws an exception
>> (ok)... But when messages are consumed, the producer remains blocked because
>> the memory isn't deallocated, so the producer remains blocked forever (also
>> if the queue became empty!). Is there a way to force queue resizing?
>>
>> Thanks.
>>
>> 2010/12/11 Stan Lewis <sl...@fusesource.com>
>>
>> You probably need to turn off producer flow control and then also
>>> enable sendFailIfNoSpace or sendFailIfNoSpaceAfterTimeout, there's a
>>> bunch of information here:
>>>
>>> http://activemq.apache.org/producer-flow-control.html
>>>
>>> On Sat, Dec 11, 2010 at 6:52 AM, Roberto Cappa <ca...@gmail.com>
>>> wrote:
>>> > Hi,
>>> >
>>> > I'm evaluating the possibility to use ActiveMQ in my project to manage
>>> a
>>> > persistent queue. I've done some tests, but I've encountered some
>>> issues.
>>> > These are my requirements:
>>> >
>>> > - All queues in my broker must be persistent, because I cannot loose
>>> pending
>>> > messages if the system goes down. This is the code, and it is ok, it
>>> works:
>>> >
>>> > BrokerService jmsBroker = new BrokerService();
>>> > jmsBroker.setPersistent(true);
>>> >
>>> > - I've to set a memory (or messages number) limit, in order to prevent
>>> too
>>> > high memory usage by the queue on my VM. This is the code:
>>> >
>>> > List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
>>> > PolicyEntry conf = new PolicyEntry();
>>> > conf.setMemoryLimit(5000000);
>>> > conf.setQueue("myQueue");
>>> > entries.add(conf);
>>> > policyMap.setPolicyEntries(entries);
>>> > jmsBroker.setDestinationPolicy(policyMap);
>>> >
>>> > This is the first problem: if setPersistent(false) it works, but if
>>> > setPersistent(true) the broker ignores the memory limit, when the
>>> memory is
>>> > full starts spooling to disk. It is an undesired behavior, persistence
>>> and
>>> > spooling are two logical separate concepts. Is there a way to set a
>>> memory
>>> > limit and persistence without enabling spooling?
>>> >
>>> > - When the memory limit is reached, by default the producer is blocked
>>> (if
>>> > persistence is false) or slowed (if persistence is true). There are two
>>> > undesired behaviors, my producer cannot be blocked or slowed by the
>>> queue (I
>>> > think it is a typical asynchronous scenario). If the queue is full, I
>>> can
>>> > choose two options, both valid for my requirements:
>>> >
>>> > - Throwing an exception in producer code, so I can take actions in
>>> case
>>> > of full queue.
>>> > - Discard oldest messages from the queue, accepting the new ones
>>> from
>>> > the producer, without blocking.
>>> >
>>> > For the first scenario, I haven't found any suitable configuration on
>>> > ActiveMQ.
>>> > For the secondo scenario, I've tryed with this code:
>>> >
>>> > OldestMessageEvictionStrategy strategy = new
>>> > OldestMessageEvictionStrategy();
>>> > conf.setMessageEvictionStrategy(strategy);
>>> > ...
>>> >
>>> > But it seems to be completely ignored. Any idea?
>>> >
>>> >
>>> > Thanks.
>>> >
>>>
>>>
>>>
>>> --
>>> Stan Lewis
>>> FuseSource
>>> Email: slewis@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: gashcrumb
>>>
>>
>>
>
Re: Persistence without spooling, memory limit, eviction policies
Posted by Roberto Cappa <ca...@gmail.com>.
Sorry, the producer isn't blocked, but it continues to throw exception like
the queue was full.
2010/12/11 Roberto Cappa <ca...@gmail.com>
> Thanks, It seems to work but...
> When the maximum of memory is reached the producer throws an exception
> (ok)... But when messages are consumed, the producer remains blocked because
> the memory isn't deallocated, so the producer remains blocked forever (also
> if the queue became empty!). Is there a way to force queue resizing?
>
> Thanks.
>
> 2010/12/11 Stan Lewis <sl...@fusesource.com>
>
> You probably need to turn off producer flow control and then also
>> enable sendFailIfNoSpace or sendFailIfNoSpaceAfterTimeout, there's a
>> bunch of information here:
>>
>> http://activemq.apache.org/producer-flow-control.html
>>
>> On Sat, Dec 11, 2010 at 6:52 AM, Roberto Cappa <ca...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > I'm evaluating the possibility to use ActiveMQ in my project to manage a
>> > persistent queue. I've done some tests, but I've encountered some
>> issues.
>> > These are my requirements:
>> >
>> > - All queues in my broker must be persistent, because I cannot loose
>> pending
>> > messages if the system goes down. This is the code, and it is ok, it
>> works:
>> >
>> > BrokerService jmsBroker = new BrokerService();
>> > jmsBroker.setPersistent(true);
>> >
>> > - I've to set a memory (or messages number) limit, in order to prevent
>> too
>> > high memory usage by the queue on my VM. This is the code:
>> >
>> > List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
>> > PolicyEntry conf = new PolicyEntry();
>> > conf.setMemoryLimit(5000000);
>> > conf.setQueue("myQueue");
>> > entries.add(conf);
>> > policyMap.setPolicyEntries(entries);
>> > jmsBroker.setDestinationPolicy(policyMap);
>> >
>> > This is the first problem: if setPersistent(false) it works, but if
>> > setPersistent(true) the broker ignores the memory limit, when the memory
>> is
>> > full starts spooling to disk. It is an undesired behavior, persistence
>> and
>> > spooling are two logical separate concepts. Is there a way to set a
>> memory
>> > limit and persistence without enabling spooling?
>> >
>> > - When the memory limit is reached, by default the producer is blocked
>> (if
>> > persistence is false) or slowed (if persistence is true). There are two
>> > undesired behaviors, my producer cannot be blocked or slowed by the
>> queue (I
>> > think it is a typical asynchronous scenario). If the queue is full, I
>> can
>> > choose two options, both valid for my requirements:
>> >
>> > - Throwing an exception in producer code, so I can take actions in
>> case
>> > of full queue.
>> > - Discard oldest messages from the queue, accepting the new ones from
>> > the producer, without blocking.
>> >
>> > For the first scenario, I haven't found any suitable configuration on
>> > ActiveMQ.
>> > For the secondo scenario, I've tryed with this code:
>> >
>> > OldestMessageEvictionStrategy strategy = new
>> > OldestMessageEvictionStrategy();
>> > conf.setMessageEvictionStrategy(strategy);
>> > ...
>> >
>> > But it seems to be completely ignored. Any idea?
>> >
>> >
>> > Thanks.
>> >
>>
>>
>>
>> --
>> Stan Lewis
>> FuseSource
>> Email: slewis@fusesource.com
>> Web: http://fusesource.com
>> Twitter: gashcrumb
>>
>
>
Re: Persistence without spooling, memory limit, eviction policies
Posted by Roberto Cappa <ca...@gmail.com>.
Thanks, It seems to work but...
When the maximum of memory is reached the producer throws an exception
(ok)... But when messages are consumed, the producer remains blocked because
the memory isn't deallocated, so the producer remains blocked forever (also
if the queue became empty!). Is there a way to force queue resizing?
Thanks.
2010/12/11 Stan Lewis <sl...@fusesource.com>
> You probably need to turn off producer flow control and then also
> enable sendFailIfNoSpace or sendFailIfNoSpaceAfterTimeout, there's a
> bunch of information here:
>
> http://activemq.apache.org/producer-flow-control.html
>
> On Sat, Dec 11, 2010 at 6:52 AM, Roberto Cappa <ca...@gmail.com>
> wrote:
> > Hi,
> >
> > I'm evaluating the possibility to use ActiveMQ in my project to manage a
> > persistent queue. I've done some tests, but I've encountered some issues.
> > These are my requirements:
> >
> > - All queues in my broker must be persistent, because I cannot loose
> pending
> > messages if the system goes down. This is the code, and it is ok, it
> works:
> >
> > BrokerService jmsBroker = new BrokerService();
> > jmsBroker.setPersistent(true);
> >
> > - I've to set a memory (or messages number) limit, in order to prevent
> too
> > high memory usage by the queue on my VM. This is the code:
> >
> > List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
> > PolicyEntry conf = new PolicyEntry();
> > conf.setMemoryLimit(5000000);
> > conf.setQueue("myQueue");
> > entries.add(conf);
> > policyMap.setPolicyEntries(entries);
> > jmsBroker.setDestinationPolicy(policyMap);
> >
> > This is the first problem: if setPersistent(false) it works, but if
> > setPersistent(true) the broker ignores the memory limit, when the memory
> is
> > full starts spooling to disk. It is an undesired behavior, persistence
> and
> > spooling are two logical separate concepts. Is there a way to set a
> memory
> > limit and persistence without enabling spooling?
> >
> > - When the memory limit is reached, by default the producer is blocked
> (if
> > persistence is false) or slowed (if persistence is true). There are two
> > undesired behaviors, my producer cannot be blocked or slowed by the queue
> (I
> > think it is a typical asynchronous scenario). If the queue is full, I can
> > choose two options, both valid for my requirements:
> >
> > - Throwing an exception in producer code, so I can take actions in
> case
> > of full queue.
> > - Discard oldest messages from the queue, accepting the new ones from
> > the producer, without blocking.
> >
> > For the first scenario, I haven't found any suitable configuration on
> > ActiveMQ.
> > For the secondo scenario, I've tryed with this code:
> >
> > OldestMessageEvictionStrategy strategy = new
> > OldestMessageEvictionStrategy();
> > conf.setMessageEvictionStrategy(strategy);
> > ...
> >
> > But it seems to be completely ignored. Any idea?
> >
> >
> > Thanks.
> >
>
>
>
> --
> Stan Lewis
> FuseSource
> Email: slewis@fusesource.com
> Web: http://fusesource.com
> Twitter: gashcrumb
>
Re: Persistence without spooling, memory limit, eviction policies
Posted by Stan Lewis <sl...@fusesource.com>.
You probably need to turn off producer flow control and then also
enable sendFailIfNoSpace or sendFailIfNoSpaceAfterTimeout, there's a
bunch of information here:
http://activemq.apache.org/producer-flow-control.html
On Sat, Dec 11, 2010 at 6:52 AM, Roberto Cappa <ca...@gmail.com> wrote:
> Hi,
>
> I'm evaluating the possibility to use ActiveMQ in my project to manage a
> persistent queue. I've done some tests, but I've encountered some issues.
> These are my requirements:
>
> - All queues in my broker must be persistent, because I cannot loose pending
> messages if the system goes down. This is the code, and it is ok, it works:
>
> BrokerService jmsBroker = new BrokerService();
> jmsBroker.setPersistent(true);
>
> - I've to set a memory (or messages number) limit, in order to prevent too
> high memory usage by the queue on my VM. This is the code:
>
> List<PolicyEntry> entries = new ArrayList<PolicyEntry>();
> PolicyEntry conf = new PolicyEntry();
> conf.setMemoryLimit(5000000);
> conf.setQueue("myQueue");
> entries.add(conf);
> policyMap.setPolicyEntries(entries);
> jmsBroker.setDestinationPolicy(policyMap);
>
> This is the first problem: if setPersistent(false) it works, but if
> setPersistent(true) the broker ignores the memory limit, when the memory is
> full starts spooling to disk. It is an undesired behavior, persistence and
> spooling are two logical separate concepts. Is there a way to set a memory
> limit and persistence without enabling spooling?
>
> - When the memory limit is reached, by default the producer is blocked (if
> persistence is false) or slowed (if persistence is true). There are two
> undesired behaviors, my producer cannot be blocked or slowed by the queue (I
> think it is a typical asynchronous scenario). If the queue is full, I can
> choose two options, both valid for my requirements:
>
> - Throwing an exception in producer code, so I can take actions in case
> of full queue.
> - Discard oldest messages from the queue, accepting the new ones from
> the producer, without blocking.
>
> For the first scenario, I haven't found any suitable configuration on
> ActiveMQ.
> For the secondo scenario, I've tryed with this code:
>
> OldestMessageEvictionStrategy strategy = new
> OldestMessageEvictionStrategy();
> conf.setMessageEvictionStrategy(strategy);
> ...
>
> But it seems to be completely ignored. Any idea?
>
>
> Thanks.
>
--
Stan Lewis
FuseSource
Email: slewis@fusesource.com
Web: http://fusesource.com
Twitter: gashcrumb