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/05/28 22:24:27 UTC
svn commit: r949282 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main:
./ activemq/core/ activemq/core/policies/
Author: tabish
Date: Fri May 28 20:24:27 2010
New Revision: 949282
URL: http://svn.apache.org/viewvc?rev=949282&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-293
Create Prefetch and Redelivery policy objects for use in ConnectionFactory configuration.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.h (with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=949282&r1=949281&r2=949282&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Fri May 28 20:24:27 2010
@@ -96,6 +96,10 @@ cc_sources = \
activemq/core/ActiveMQSessionExecutor.cpp \
activemq/core/ActiveMQTransactionContext.cpp \
activemq/core/MessageDispatchChannel.cpp \
+ activemq/core/PrefetchPolicy.cpp \
+ activemq/core/RedeliveryPolicy.cpp \
+ activemq/core/policies/DefaultPrefetchPolicy.cpp \
+ activemq/core/policies/DefaultRedeliveryPolicy.cpp \
activemq/exceptions/ActiveMQException.cpp \
activemq/io/LoggingInputStream.cpp \
activemq/io/LoggingOutputStream.cpp \
@@ -735,7 +739,11 @@ h_sources = \
activemq/core/DispatchData.h \
activemq/core/Dispatcher.h \
activemq/core/MessageDispatchChannel.h \
+ activemq/core/PrefetchPolicy.h \
+ activemq/core/RedeliveryPolicy.h \
activemq/core/Synchronization.h \
+ activemq/core/policies/DefaultPrefetchPolicy.h \
+ activemq/core/policies/DefaultRedeliveryPolicy.h \
activemq/exceptions/ActiveMQException.h \
activemq/exceptions/BrokerException.h \
activemq/exceptions/ExceptionDefines.h \
Added: 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=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp Fri May 28 20:24:27 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "PrefetchPolicy.h"
+
+using namespace activemq;
+using namespace activemq::core;
+
+////////////////////////////////////////////////////////////////////////////////
+PrefetchPolicy::PrefetchPolicy() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrefetchPolicy::~PrefetchPolicy() {
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h Fri May 28 20:24:27 2010
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_CORE_PREFETCHPOLICY_H_
+#define _ACTIVEMQ_CORE_PREFETCHPOLICY_H_
+
+#include <activemq/util/Config.h>
+
+namespace activemq {
+namespace core {
+
+ /**
+ * Interface for a Policy object that controls message Prefetching on various
+ * destination types in ActiveMQ-CPP.
+ *
+ * @since 3.2.0
+ */
+ class AMQCPP_API PrefetchPolicy {
+ private:
+
+ PrefetchPolicy( const PrefetchPolicy& );
+ PrefetchPolicy& operator= ( const PrefetchPolicy& );
+
+ protected:
+
+ PrefetchPolicy();
+
+ public:
+
+ virtual ~PrefetchPolicy();
+
+ /**
+ * Sets the amount of prefetched messages for a Durable Topic.
+ *
+ * @param value
+ * The number of messages to prefetch.
+ */
+ virtual void setDurableTopicPrefetch( int value ) = 0;
+
+ /**
+ * Gets the amount of messages to prefetch for a Durable Topic.
+ *
+ * @returns value of the number of messages to prefetch.
+ */
+ virtual int getDurableTopicPrefetch() const = 0;
+
+ /**
+ * Sets the amount of prefetched messages for a Queue.
+ *
+ * @param value
+ * The number of messages to prefetch.
+ */
+ virtual void setQueuePrefetch( int value ) = 0;
+
+ /**
+ * Gets the amount of messages to prefetch for a Queue.
+ *
+ * @returns value of the number of messages to prefetch.
+ */
+ virtual int getQueuePrefetch() const = 0;
+
+ /**
+ * Sets the amount of prefetched messages for a Queue Browser.
+ *
+ * @param value
+ * The number of messages to prefetch.
+ */
+ virtual void setQueueBrowserPrefetch( int value ) = 0;
+
+ /**
+ * Gets the amount of messages to prefetch for a Queue Browser.
+ *
+ * @returns value of the number of messages to prefetch.
+ */
+ virtual int getQueueBrowserPrefetch() const = 0;
+
+ /**
+ * Sets the amount of prefetched messages for a Topic.
+ *
+ * @param value
+ * The number of messages to prefetch.
+ */
+ virtual void setTopicPrefetch( int value ) = 0;
+
+ /**
+ * Gets the amount of messages to prefetch for a Topic.
+ *
+ * @returns value of the number of messages to prefetch.
+ */
+ virtual int getTopicPrefetch() const = 0;
+
+ /**
+ * Given a requested value for a new prefetch limit, compare it against some max
+ * prefetch value and return either the requested value or the maximum allowable
+ * value for prefetch.
+ *
+ * @returns the allowable value for a prefetch limit, either requested or the max.
+ */
+ virtual int getMaxPrefetchLimit( int value ) const = 0;
+
+ /**
+ * Clone the Policy and return a new pointer to that clone.
+ *
+ * @return pointer to a new PrefetchPolicy instance that is a clone of this one.
+ */
+ virtual PrefetchPolicy* clone() const = 0;
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_CORE_PREFETCHPOLICY_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/PrefetchPolicy.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp Fri May 28 20:24:27 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RedeliveryPolicy.h"
+
+using namespace activemq;
+using namespace activemq::core;
+
+////////////////////////////////////////////////////////////////////////////////
+RedeliveryPolicy::RedeliveryPolicy() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+RedeliveryPolicy::~RedeliveryPolicy() {
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h Fri May 28 20:24:27 2010
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_CORE_REDELIVERYPOLICY_H_
+#define _ACTIVEMQ_CORE_REDELIVERYPOLICY_H_
+
+#include <activemq/util/Config.h>
+
+namespace activemq {
+namespace core {
+
+ /**
+ * Interface for a RedeliveryPolicy object that controls how message Redelivery is
+ * handled in ActiveMQ-CPP when a transaction is rolled back.
+ *
+ * @since 3.2.0
+ */
+ class AMQCPP_API RedeliveryPolicy {
+ private:
+
+ RedeliveryPolicy( const RedeliveryPolicy& );
+ RedeliveryPolicy& operator= ( const RedeliveryPolicy& );
+
+ protected:
+
+ RedeliveryPolicy();
+
+ public:
+
+ virtual ~RedeliveryPolicy();
+
+ /**
+ * @returns The value of the Back-Off Multiplier for Message Redelivery.
+ */
+ virtual double getBackOffMultiplier() const = 0;
+
+ /**
+ * Sets the Back-Off Multiplier for Message Redelivery.
+ *
+ * @param value
+ * The new value for the back-off multiplier.
+ */
+ virtual void setBackOffMultiplier( double value ) = 0;
+
+ /**
+ * @returns the currently set Collision Avoidance percentage.
+ */
+ virtual short getCollisionAvoidancePercent() const = 0;
+
+ /**
+ * @param value
+ * The collision avoidance percentage setting.
+ */
+ virtual void setCollisionAvoidancePercent( short value ) = 0;
+
+ /**
+ * Gets the initial time that redelivery of messages is delayed.
+ *
+ * @returns the time in milliseconds that redelivery is delayed initially.
+ */
+ virtual long long getInitialRedeliveryDelay() const = 0;
+
+ /**
+ * Sets the initial time that redelivery will be delayed.
+ *
+ * @param value
+ * Time in Milliseconds to wait before starting redelivery.
+ */
+ virtual void setInitialRedeliveryDelay( long long value ) = 0;
+
+ /**
+ * Gets the Maximum number of allowed redeliveries for a message before it will
+ * be discarded by the consumer.
+ *
+ * @returns maximum allowed redeliveries for a message.
+ */
+ virtual int getMaximumRedeliveries() const = 0;
+
+ /**
+ * Sets the Maximum allowable redeliveries for a Message.
+ *
+ * @param maximumRedeliveries
+ * The maximum number of times that a message will be redelivered.
+ */
+ virtual void setMaximumRedeliveries( int maximumRedeliveries ) = 0;
+
+ /**
+ * Given the last used redelivery delay calculate the next value of the delay
+ * based on the settings in this Policy instance.
+ *
+ * @param previousDelay
+ * The last delay that was used between message redeliveries.
+ *
+ * @return the new delay to use before attempting another redelivery.
+ */
+ virtual long long getRedeliveryDelay( long long previousDelay ) = 0;
+
+ /**
+ * @returns whether or not collision avoidance is enabled for this Policy.
+ */
+ virtual bool isUseCollisionAvoidance() const = 0;
+
+ /**
+ * @param value
+ * Enable or Disable collision avoidance for this Policy.
+ */
+ virtual void setUseCollisionAvoidance( bool value ) = 0;
+
+ /**
+ * @returns whether or not the exponential back off option is enabled.
+ */
+ virtual bool isUseExponentialBackOff() const = 0;
+
+ /**
+ * @param value
+ * Enable or Disable the exponential back off multiplier option.
+ */
+ virtual void setUseExponentialBackOff( bool value ) = 0;
+
+ /**
+ * Create a copy of this Policy and return it.
+ *
+ * @return pointer to a new RedeliveryPolicy that is a copy of this one.
+ */
+ virtual RedeliveryPolicy* clone() const = 0;
+
+ };
+
+}}
+
+#endif /* _ACTIVEMQ_CORE_REDELIVERYPOLICY_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/RedeliveryPolicy.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.cpp?rev=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.cpp Fri May 28 20:24:27 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DefaultPrefetchPolicy.h"
+
+#include <decaf/lang/Short.h>
+
+using namespace activemq;
+using namespace activemq::core;
+using namespace activemq::core::policies;
+using namespace decaf;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+int DefaultPrefetchPolicy::MAX_PREFETCH_SIZE = Short::MAX_VALUE - 1;
+int DefaultPrefetchPolicy::DEFAULT_DURABLE_TOPIC_PREFETCH = 100;
+int DefaultPrefetchPolicy::DEFAULT_QUEUE_PREFETCH = 1000;
+int DefaultPrefetchPolicy::DEFAULT_QUEUE_BROWSER_PREFETCH = 500;
+int DefaultPrefetchPolicy::DEFAULT_TOPIC_PREFETCH = MAX_PREFETCH_SIZE;
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultPrefetchPolicy::DefaultPrefetchPolicy() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultPrefetchPolicy::~DefaultPrefetchPolicy() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+PrefetchPolicy* DefaultPrefetchPolicy::clone() const {
+
+ DefaultPrefetchPolicy* copy = new DefaultPrefetchPolicy;
+
+ copy->setDurableTopicPrefetch( this->getDurableTopicPrefetch() );
+ copy->setTopicPrefetch( this->getTopicPrefetch() );
+ copy->setQueueBrowserPrefetch( this->getQueueBrowserPrefetch() );
+ copy->setQueuePrefetch( this->getQueuePrefetch() );
+
+ return copy;
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.h?rev=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.h Fri May 28 20:24:27 2010
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_CORE_POLICIES_DEFAULTPREFETCHPOLICY_H_
+#define _ACTIVEMQ_CORE_POLICIES_DEFAULTPREFETCHPOLICY_H_
+
+#include <activemq/util/Config.h>
+
+#include <activemq/core/PrefetchPolicy.h>
+
+namespace activemq {
+namespace core {
+namespace policies {
+
+ class AMQCPP_API DefaultPrefetchPolicy : public PrefetchPolicy {
+ private:
+
+ int durableTopicPrefetch;
+ int queuePrefetch;
+ int queueBrowserPrefetch;
+ int topicPrefetch;
+
+ public:
+
+ static int MAX_PREFETCH_SIZE;
+ static int DEFAULT_DURABLE_TOPIC_PREFETCH;
+ static int DEFAULT_QUEUE_PREFETCH;
+ static int DEFAULT_QUEUE_BROWSER_PREFETCH;
+ static int DEFAULT_TOPIC_PREFETCH;
+
+ private:
+
+ DefaultPrefetchPolicy( const DefaultPrefetchPolicy& );
+ DefaultPrefetchPolicy& operator= ( DefaultPrefetchPolicy& );
+
+ public:
+
+ DefaultPrefetchPolicy();
+
+ virtual ~DefaultPrefetchPolicy();
+
+ virtual void setDurableTopicPrefetch( int value ) {
+ this->durableTopicPrefetch = getMaxPrefetchLimit( value );
+ }
+
+ virtual int getDurableTopicPrefetch() const {
+ return this->durableTopicPrefetch;
+ }
+
+ virtual void setQueuePrefetch( int value ) {
+ this->queuePrefetch = getMaxPrefetchLimit( value );
+ }
+
+ virtual int getQueuePrefetch() const {
+ return this->queuePrefetch;
+ }
+
+ virtual void setQueueBrowserPrefetch( int value ) {
+ this->queueBrowserPrefetch = getMaxPrefetchLimit( value );
+ }
+
+ virtual int getQueueBrowserPrefetch() const {
+ return this->queueBrowserPrefetch;
+ }
+
+ virtual void setTopicPrefetch( int value ) {
+ this->topicPrefetch = getMaxPrefetchLimit( value );
+ }
+
+ virtual int getTopicPrefetch() const {
+ return this->topicPrefetch;
+ }
+
+ virtual int getMaxPrefetchLimit( int value ) const {
+ return value < MAX_PREFETCH_SIZE ? value : MAX_PREFETCH_SIZE;
+ }
+
+ virtual PrefetchPolicy* clone() const;
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_CORE_POLICIES_DEFAULTPREFETCHPOLICY_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultPrefetchPolicy.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.cpp?rev=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.cpp Fri May 28 20:24:27 2010
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DefaultRedeliveryPolicy.h"
+
+#include <decaf/lang/Math.h>
+#include <decaf/util/Random.h>
+
+using namespace activemq;
+using namespace activemq::core;
+using namespace activemq::core::policies;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultRedeliveryPolicy::DefaultRedeliveryPolicy() {
+
+ this->collisionAvoidanceFactor = 0.15;
+ this->maximumRedeliveries = 6;
+ this->initialRedeliveryDelay = 1000LL;
+ this->useCollisionAvoidance = false;
+ this->useExponentialBackOff = false;
+ this->backOffMultiplier = 5.0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+DefaultRedeliveryPolicy::~DefaultRedeliveryPolicy() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+short DefaultRedeliveryPolicy::getCollisionAvoidancePercent() const {
+ return (short)Math::round( this->collisionAvoidanceFactor * 100 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void DefaultRedeliveryPolicy::setCollisionAvoidancePercent( short value ) {
+ this->collisionAvoidanceFactor = value * 0.01;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+long long DefaultRedeliveryPolicy::getRedeliveryDelay( long long previousDelay ) {
+
+ static Random randomNumberGenerator;
+
+ long long redeliveryDelay;
+
+ if( previousDelay == 0 ) {
+ redeliveryDelay = initialRedeliveryDelay;
+ } else if( useExponentialBackOff && (int)backOffMultiplier > 1 ) {
+ redeliveryDelay = (long long)( (double)previousDelay * backOffMultiplier );
+ } else {
+ redeliveryDelay = previousDelay;
+ }
+
+ if( useCollisionAvoidance ) {
+ /*
+ * First random determines +/-, second random determines how far to
+ * go in that direction. -cgs
+ */
+ double variance = ( randomNumberGenerator.nextBoolean() ?
+ collisionAvoidanceFactor : -collisionAvoidanceFactor ) * randomNumberGenerator.nextDouble( );
+ redeliveryDelay += (long long)( (double)redeliveryDelay * variance );
+ }
+
+ return redeliveryDelay;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+RedeliveryPolicy* DefaultRedeliveryPolicy::clone() const {
+
+ DefaultRedeliveryPolicy* copy = new DefaultRedeliveryPolicy;
+
+ copy->collisionAvoidanceFactor = this->collisionAvoidanceFactor;
+ copy->maximumRedeliveries = this->maximumRedeliveries;
+ copy->initialRedeliveryDelay = this->initialRedeliveryDelay;
+ copy->useCollisionAvoidance = this->useCollisionAvoidance;
+ copy->useExponentialBackOff = this->useExponentialBackOff;
+ copy->backOffMultiplier = this->backOffMultiplier;
+
+ return copy;
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.h?rev=949282&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.h Fri May 28 20:24:27 2010
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_CORE_POLICIES_DEFAULTREDELIVERYPOLICY_H_
+#define _ACTIVEMQ_CORE_POLICIES_DEFAULTREDELIVERYPOLICY_H_
+
+#include <activemq/util/Config.h>
+
+#include <activemq/core/RedeliveryPolicy.h>
+
+namespace activemq {
+namespace core {
+namespace policies {
+
+ class AMQCPP_API DefaultRedeliveryPolicy : public RedeliveryPolicy {
+ private:
+
+ double backOffMultiplier;
+ double collisionAvoidanceFactor;
+ long long initialRedeliveryDelay;
+ int maximumRedeliveries;
+ bool useCollisionAvoidance;
+ bool useExponentialBackOff;
+
+ private:
+
+ DefaultRedeliveryPolicy( const DefaultRedeliveryPolicy& );
+ DefaultRedeliveryPolicy& operator= ( const DefaultRedeliveryPolicy& );
+
+ public:
+
+ DefaultRedeliveryPolicy();
+
+ virtual ~DefaultRedeliveryPolicy();
+
+ virtual double getBackOffMultiplier() const {
+ return this->backOffMultiplier;
+ }
+
+ virtual void setBackOffMultiplier( double value ) {
+ this->backOffMultiplier = value;
+ }
+
+ virtual short getCollisionAvoidancePercent() const;
+
+ virtual void setCollisionAvoidancePercent( short value );
+
+ virtual long long getInitialRedeliveryDelay() const {
+ return this->initialRedeliveryDelay;
+ }
+
+ virtual void setInitialRedeliveryDelay( long long value ) {
+ this->initialRedeliveryDelay = value;
+ }
+
+ virtual int getMaximumRedeliveries() const {
+ return this->maximumRedeliveries;
+ }
+
+ virtual void setMaximumRedeliveries( int value ) {
+ this->maximumRedeliveries = value;
+ }
+
+ virtual bool isUseCollisionAvoidance() const {
+ return this->useCollisionAvoidance;
+ }
+
+ virtual void setUseCollisionAvoidance( bool value ) {
+ this->useCollisionAvoidance = value;
+ }
+
+ virtual bool isUseExponentialBackOff() const {
+ return this->useExponentialBackOff;
+ }
+
+ virtual void setUseExponentialBackOff( bool value ) {
+ this->useExponentialBackOff = value;
+ }
+
+ virtual long long getRedeliveryDelay( long long previousDelay );
+
+ virtual RedeliveryPolicy* clone() const;
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQ_CORE_POLICIES_DEFAULTREDELIVERYPOLICY_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/policies/DefaultRedeliveryPolicy.h
------------------------------------------------------------------------------
svn:eol-style = native