You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by goku <fa...@gmail.com> on 2011/04/25 02:46:34 UTC
Questions about Cache,Acknowledged, and Prefetch limit
Hi,
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://192.168.9.12:61616");
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)
cCount++;
}
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
cf.getPrefetchPolicy().setQueuePrefetch(5000);
and
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
http://activemq.apache.org/what-is-the-prefetch-limit-for.html
Based on my understanding, if I set the prefetch size to 1 for example,
cf.getPrefetchPolicy().setQueuePrefetch(1);
and
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: http://activemq.2283324.n4.nabble.com/Questions-about-Cache-Acknowledged-and-Prefetch-limit-tp3472368p3472368.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.