Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03D54957E for ; Fri, 8 Jun 2012 20:19:33 +0000 (UTC) Received: (qmail 5342 invoked by uid 500); 8 Jun 2012 20:19:32 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 5266 invoked by uid 500); 8 Jun 2012 20:19:32 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 5259 invoked by uid 99); 8 Jun 2012 20:19:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 20:19:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 20:19:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3D9F92388A32 for ; Fri, 8 Jun 2012 20:19:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1348229 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/activemq/core/kernels/ActiveMQConsumerKernel.cpp test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp test-integration/activemq/test/openwire/OpenwireSimpleTest.h Date: Fri, 08 Jun 2012 20:19:11 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120608201911.3D9F92388A32@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Fri Jun 8 20:19:10 2012 New Revision: 1348229 URL: http://svn.apache.org/viewvc?rev=1348229&view=rev Log: fix for: https://issues.apache.org/jira/browse/AMQCPP-410 Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp?rev=1348229&r1=1348228&r2=1348229&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.cpp Fri Jun 8 20:19:10 2012 @@ -337,10 +337,6 @@ ActiveMQConsumerKernel::ActiveMQConsumer } } - if (prefetch < 0) { - throw IllegalArgumentException(__FILE__, __LINE__, "Cannot create a consumer with a negative prefetch"); - } - this->internal = new ActiveMQConsumerKernelConfig(); Pointer consumerInfo(new ConsumerInfo()); @@ -380,6 +376,10 @@ ActiveMQConsumerKernel::ActiveMQConsumer } applyDestinationOptions(this->consumerInfo); + + if (this->consumerInfo->getPrefetchSize() < 0) { + throw IllegalArgumentException(__FILE__, __LINE__, "Cannot create a consumer with a negative prefetch"); + } } //////////////////////////////////////////////////////////////////////////////// @@ -1298,7 +1298,7 @@ void ActiveMQConsumerKernel::applyDestin } std::string prefetchSizeStr = core::ActiveMQConstants::toString(core::ActiveMQConstants::CONSUMER_PREFECTCHSIZE); - if (info->getPrefetchSize() <= 0 || options.hasProperty(prefetchSizeStr)) { + if (options.hasProperty(prefetchSizeStr)) { info->setPrefetchSize(Integer::parseInt(options.getProperty(prefetchSizeStr, "1000"))); } Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp?rev=1348229&r1=1348228&r2=1348229&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp Fri Jun 8 20:19:10 2012 @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -67,6 +68,30 @@ void OpenwireSimpleTest::testWithZeroCon } //////////////////////////////////////////////////////////////////////////////// +void OpenwireSimpleTest::testWithZeroConsumerPrefetch2() { + + cmsProvider->setTopic( false ); + ActiveMQConnection* amqConnection = dynamic_cast(cmsProvider->getConnection()); + amqConnection->getPrefetchPolicy()->setQueuePrefetch(0); + amqConnection->getPrefetchPolicy()->setTopicPrefetch(0); + cmsProvider->reconnectSession(); + + // Create CMS Object for Comms + cms::Session* session( cmsProvider->getSession() ); + cms::MessageConsumer* consumer = cmsProvider->getConsumer(); + cms::MessageProducer* producer = cmsProvider->getProducer(); + producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT ); + + auto_ptr txtMessage( session->createTextMessage( "TEST MESSAGE" ) ); + + // Send some text messages + producer->send( txtMessage.get() ); + + auto_ptr message( consumer->receive( 1000 ) ); + CPPUNIT_ASSERT( message.get() != NULL ); +} + +//////////////////////////////////////////////////////////////////////////////// void OpenwireSimpleTest::testWithZeroConsumerPrefetchAndNoMessage() { cmsProvider->setTopic( false ); @@ -92,6 +117,31 @@ void OpenwireSimpleTest::testWithZeroCon } //////////////////////////////////////////////////////////////////////////////// +void OpenwireSimpleTest::testWithZeroConsumerPrefetchAndNoMessage2() { + + cmsProvider->setTopic( false ); + ActiveMQConnection* amqConnection = dynamic_cast(cmsProvider->getConnection()); + amqConnection->getPrefetchPolicy()->setQueuePrefetch(0); + amqConnection->getPrefetchPolicy()->setTopicPrefetch(0); + cmsProvider->reconnectSession(); + + // Create CMS Object for Comms + cms::Session* session( cmsProvider->getSession() ); + cms::MessageConsumer* consumer = cmsProvider->getConsumer(); + + // Should be no message and no exceptions + auto_ptr message( consumer->receiveNoWait() ); + CPPUNIT_ASSERT( message.get() == NULL ); + + // Should be no message and no exceptions + message.reset( consumer->receive(1000) ); + CPPUNIT_ASSERT( message.get() == NULL ); + + consumer->close(); + session->close(); +} + +//////////////////////////////////////////////////////////////////////////////// void OpenwireSimpleTest::testMapMessageSendToQueue() { cmsProvider->setTopic( false ); Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h?rev=1348229&r1=1348228&r2=1348229&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h Fri Jun 8 20:19:10 2012 @@ -41,6 +41,8 @@ namespace openwire{ CPPUNIT_TEST( testQuickCreateAndDestroy ); CPPUNIT_TEST( testWithZeroConsumerPrefetch ); CPPUNIT_TEST( testWithZeroConsumerPrefetchAndNoMessage ); + CPPUNIT_TEST( testWithZeroConsumerPrefetch2 ); + CPPUNIT_TEST( testWithZeroConsumerPrefetchAndNoMessage2 ); CPPUNIT_TEST( testMapMessageSendToQueue ); CPPUNIT_TEST( testMapMessageSendToTopic ); CPPUNIT_TEST( testDestroyDestination ); @@ -59,6 +61,8 @@ namespace openwire{ void testWithZeroConsumerPrefetch(); void testWithZeroConsumerPrefetchAndNoMessage(); + void testWithZeroConsumerPrefetch2(); + void testWithZeroConsumerPrefetchAndNoMessage2(); void testMapMessageSendToQueue(); void testMapMessageSendToTopic(); void tesstStreamMessage();