On 04/25/2013 07:00 AM, erngarfen wrote:
Hi all,
I've been struggling with this for a while now, but still can't get my
client to receive all the messages from a queue. I'm using ActiveMQ 5.8.0 as
the broker and ActiveMQ-CPP for the client (see simple test code below). At
the broker I have a queue filled with 1000 messages (done from a separate
python script). When I try to receive these, I usually end up with 575 or
588 received messages. Trying some combinations of 'prefetch' doesn't help
me either. If I start to acknowledge messages, I'll receive the 1000
messages.
I can see in Wireshark that 'MessagePull' is sent to the broker but the
'MessageDispatch' reply doesn't contain the 'message body'.
Any help appreciated.
Thanks.
#include "activemq/library/ActiveMQCPP.h"
#include "cms/ConnectionFactory.h"
#include "cms/Connection.h"
#include "cms/Session.h"
#include <iostream>
int main()
{
using namespace cms;
using namespace activemq::library;
ActiveMQCPP::initializeLibrary();
ConnectionFactory* lFactory =
ConnectionFactory::createCMSConnectionFactory("tcp://10.178.230.119:61616?jms.prefetchPolicy.queuePrefetch=0");
Connection* lConnection = lFactory->createConnection();
Session* lSession =
lConnection->createSession(Session::INDIVIDUAL_ACKNOWLEDGE);
Queue* lQueue =
lSession->createQueue("cmd.queue?consumer.prefetchSize=0");
MessageConsumer* lConsumer = lSession->createConsumer(lQueue);
const ConnectionMetaData* lMetaData = lConnection->getMetaData();
std::cout << "AMQ version=" << lMetaData->getProviderVersion() <<
std::endl;
lSession->start();
int lCnt = 0;
while (true)
{
if (Message* lMsg = lConsumer->receive(1000))
{
std::cout << "Received msg #" << ++lCnt << std::endl;
delete lMsg;
}
}
}
--
View this message in context:
http://activemq.2283324.n4.nabble.com/Not-receiving-all-msgs-from-queue-tp4666192.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Is your producer blocking be cause its being flow controlled. You
aren't acking the messages so space won't be free in memory usage until
you do.
--
Tim Bish
Sr Software Engineer | RedHat Inc.
[email protected] | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/