You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/06/03 21:15:58 UTC
svn commit: r951121 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core:
ActiveMQConnectionFactory.cpp PrefetchPolicy.cpp PrefetchPolicy.h
RedeliveryPolicy.cpp RedeliveryPolicy.h
Author: tabish
Date: Thu Jun 3 19:15:57 2010
New Revision: 951121
URL: http://svn.apache.org/viewvc?rev=951121&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-293
Add a configure method to the Policy interfaces and calls it from the ConnectionFactory
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp?rev=951121&r1=951120&r2=951121&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQConnectionFactory.cpp Thu Jun 3 19:15:57 2010
@@ -143,6 +143,9 @@ namespace core{
this->password = properties->getProperty(
core::ActiveMQConstants::toString(
core::ActiveMQConstants::PARAM_PASSWORD ), "" );
+
+ this->defaultPrefetchPolicy->configure( *properties );
+ this->defaultRedeliveryPolicy->configure( *properties );
}
};
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp?rev=951121&r1=951120&r2=951121&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp Thu Jun 3 19:15:57 2010
@@ -17,8 +17,12 @@
#include "PrefetchPolicy.h"
+#include <decaf/lang/Integer.h>
+
using namespace activemq;
using namespace activemq::core;
+using namespace decaf;
+using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
PrefetchPolicy::PrefetchPolicy() {
@@ -27,3 +31,29 @@ PrefetchPolicy::PrefetchPolicy() {
////////////////////////////////////////////////////////////////////////////////
PrefetchPolicy::~PrefetchPolicy() {
}
+
+////////////////////////////////////////////////////////////////////////////////
+void PrefetchPolicy::configure( const decaf::util::Properties& properties ) {
+
+ try{
+
+ if( properties.hasProperty( "cms.PrefetchPolicy.durableTopicPrefetch" ) ) {
+ this->setDurableTopicPrefetch( Integer::parseInt(
+ properties.getProperty( "cms.PrefetchPolicy.durableTopicPrefetch" ) ) );
+ }
+ if( properties.hasProperty( "cms.PrefetchPolicy.queueBrowserPrefetch" ) ) {
+ this->setQueueBrowserPrefetch( Integer::parseInt(
+ properties.getProperty( "cms.PrefetchPolicy.queueBrowserPrefetch" ) ) );
+ }
+ if( properties.hasProperty( "cms.PrefetchPolicy.queuePrefetch" ) ) {
+ this->setQueuePrefetch( Integer::parseInt(
+ properties.getProperty( "cms.PrefetchPolicy.queuePrefetch" ) ) );
+ }
+ if( properties.hasProperty( "cms.PrefetchPolicy.topicPrefetch" ) ) {
+ this->setTopicPrefetch( Integer::parseInt(
+ properties.getProperty( "cms.PrefetchPolicy.topicPrefetch" ) ) );
+ }
+ }
+ DECAF_CATCH_RETHROW( Exception )
+ DECAF_CATCHALL_THROW( Exception )
+}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h?rev=951121&r1=951120&r2=951121&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h Thu Jun 3 19:15:57 2010
@@ -20,6 +20,8 @@
#include <activemq/util/Config.h>
+#include <decaf/util/Properties.h>
+
namespace activemq {
namespace core {
@@ -119,6 +121,24 @@ namespace core {
*/
virtual PrefetchPolicy* clone() const = 0;
+ /**
+ * Checks the supplied properties object for properties matching the configurable
+ * settings of this class. The default implementation looks for properties named
+ * with the prefix cms.PrefetchPolicy.XXX where XXX is the name of a property with
+ * a public setter method. For instance cms.PrefetchPolicy.topicPrefetch will be
+ * used to set the value of the topic prefetch limit.
+ *
+ * Subclasses can override this method to add more configuration options or to exclude
+ * certain parameters from being set via the properties object.
+ *
+ * @param properties
+ * The Properties object used to configure this object.
+ *
+ * @throws NumberFormatException if a property that is numeric cannot be converted
+ * @throws IllegalArgumentException if a property can't be converted to the correct type.
+ */
+ virtual void configure( const decaf::util::Properties& properties );
+
};
}}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp?rev=951121&r1=951120&r2=951121&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp Thu Jun 3 19:15:57 2010
@@ -17,8 +17,16 @@
#include "RedeliveryPolicy.h"
+#include <decaf/lang/Boolean.h>
+#include <decaf/lang/Double.h>
+#include <decaf/lang/Short.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Long.h>
+
using namespace activemq;
using namespace activemq::core;
+using namespace decaf;
+using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
RedeliveryPolicy::RedeliveryPolicy() {
@@ -27,3 +35,37 @@ RedeliveryPolicy::RedeliveryPolicy() {
////////////////////////////////////////////////////////////////////////////////
RedeliveryPolicy::~RedeliveryPolicy() {
}
+
+////////////////////////////////////////////////////////////////////////////////
+void RedeliveryPolicy::configure( const decaf::util::Properties& properties ) {
+
+ try{
+
+ if( properties.hasProperty( "cms.RedeliveryPolicy.backOffMultiplier" ) ) {
+ this->setBackOffMultiplier( Double::parseDouble(
+ properties.getProperty( "cms.RedeliveryPolicy.backOffMultiplier" ) ) );
+ }
+ if( properties.hasProperty( "cms.RedeliveryPolicy.collisionAvoidancePercent" ) ) {
+ this->setCollisionAvoidancePercent( Short::parseShort(
+ properties.getProperty( "cms.RedeliveryPolicy.collisionAvoidancePercent" ) ) );
+ }
+ if( properties.hasProperty( "cms.RedeliveryPolicy.initialRedeliveryDelay" ) ) {
+ this->setInitialRedeliveryDelay( Long::parseLong(
+ properties.getProperty( "cms.RedeliveryPolicy.initialRedeliveryDelay" ) ) );
+ }
+ if( properties.hasProperty( "cms.RedeliveryPolicy.maximumRedeliveries" ) ) {
+ this->setMaximumRedeliveries( Integer::parseInt(
+ properties.getProperty( "cms.RedeliveryPolicy.maximumRedeliveries" ) ) );
+ }
+ if( properties.hasProperty( "cms.RedeliveryPolicy.useCollisionAvoidance" ) ) {
+ this->setUseCollisionAvoidance( Boolean::parseBoolean(
+ properties.getProperty( "cms.RedeliveryPolicy.useCollisionAvoidance" ) ) );
+ }
+ if( properties.hasProperty( "cms.RedeliveryPolicy.useExponentialBackOff" ) ) {
+ this->setUseExponentialBackOff( Boolean::parseBoolean(
+ properties.getProperty( "cms.RedeliveryPolicy.useExponentialBackOff" ) ) );
+ }
+ }
+ DECAF_CATCH_RETHROW( Exception )
+ DECAF_CATCHALL_THROW( Exception )
+}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h?rev=951121&r1=951120&r2=951121&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h Thu Jun 3 19:15:57 2010
@@ -20,6 +20,8 @@
#include <activemq/util/Config.h>
+#include <decaf/util/Properties.h>
+
namespace activemq {
namespace core {
@@ -138,6 +140,24 @@ namespace core {
*/
virtual RedeliveryPolicy* clone() const = 0;
+ /**
+ * Checks the supplied properties object for properties matching the configurable
+ * settings of this class. The default implementation looks for properties named
+ * with the prefix cms.RedeliveryPolicy.XXX where XXX is the name of a property with
+ * a public setter method. For instance cms.RedeliveryPolicy.useExponentialBackOff
+ * will be used to set the value of the use exponential back off toggle.
+ *
+ * Subclasses can override this method to add more configuration options or to exclude
+ * certain parameters from being set via the properties object.
+ *
+ * @param properties
+ * The Properties object used to configure this object.
+ *
+ * @throws NumberFormatException if a property that is numeric cannot be converted
+ * @throws IllegalArgumentException if a property can't be converted to the correct type.
+ */
+ virtual void configure( const decaf::util::Properties& properties );
+
};
}}