activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From goku <>
Subject Questions about Cache,Acknowledged, and Prefetch limit
Date Mon, 25 Apr 2011 00:46:34 GMT

I'm very new to JMS and activeMQ. I have some questions regarding
Cache,Acknowledged, and Prefetch limit

Here is my scenario.

1. I'm using Apache Activemq 5.5.0

2. Let's say I have 1500 messages in a queue (test.testQ). 
For the first 1499 messages, I set message.setStringProperty("type","0"). 
For the last message (1500th), "type" string property is set to "1".

3. I create one consumer with Session.CLIENT_ACKNOWLEDGE and receive
messages in a while loop consumer.receive(timeoutMs) method with a timeout
of 10s. 

Note that I haven't acknowledged any message in my scenario.
For example,

cf = new ActiveMQConnectionFactory("tcp://");
queue = new ActiveMQQueue("test.testQ");											
connection = cf.createConnection();
session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
messageConsumer = session.createConsumer(queue,null);
int count = 0;
while( (cMessage = messageConsumer.receive(10000)) != null)

Here is my questions.

1. The cCount result is 675. What configurations contribute to the limit of
675 result count instead of 1500? What should I do if I want to see all
those messages (1500 as a result). 
I've tried 
queue = new ActiveMQQueue("test.testQ?consumer.prefetchSize=5000");

but still get the same result of 675.

2. I've read a description of prefetch limit from
Based on my understanding, if I set the prefetch size to 1 for example,

queue = new ActiveMQQueue("test.testQ?consumer.prefetchSize=1");

I should see the cCount result of 1 since I haven't acknowledged any
message. Am I correct?

3. What is the best way for me to get to the 1500th message if a lot of
messages in front of it are not acknowledged yet?

I've tried message selector, for example 
messageConsumer = session.createConsumer(queue,"type='1'");

But it doesn't return the message. I think this is due to prefetch limit. Am
I right? 
Ideally, I don't want to increase prefetch limit, does anyone know a way to
use message selector to ask Message Broker to push the client certain
messages directly without getting into prefetch limit on the client side? I
assume there is a message consumer internal queue in ActiveMQ to support
this prefetch. Basically, I'd like to know if there is a way to by pass it. 
Thank you in advance for your help!

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message