activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
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 GMT
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> 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 <activemq/util/CMSListener.h>
 #include <activemq/core/ActiveMQConnection.h>
+#include <activemq/core/PrefetchPolicy.h>
 #include <activemq/exceptions/ActiveMQException.h>
 
 #include <decaf/util/UUID.h>
@@ -67,6 +68,30 @@ void OpenwireSimpleTest::testWithZeroCon
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void OpenwireSimpleTest::testWithZeroConsumerPrefetch2() {
+
+    cmsProvider->setTopic( false );
+    ActiveMQConnection* amqConnection = dynamic_cast<ActiveMQConnection*>(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<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE"
) );
+
+    // Send some text messages
+    producer->send( txtMessage.get() );
+
+    auto_ptr<cms::Message> 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<ActiveMQConnection*>(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<cms::Message> 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();



Mime
View raw message