You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by nm...@apache.org on 2006/11/27 02:36:59 UTC
svn commit: r479490 - in
/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main:
activemq/core/ActiveMQProducer.cpp activemq/core/ActiveMQProducer.h
cms/MessageProducer.h
Author: nmittler
Date: Sun Nov 26 17:36:58 2006
New Revision: 479490
URL: http://svn.apache.org/viewvc?view=rev&rev=479490
Log:
[AMQCPP-14] Added the proper handling of the CMS Message Expiration value
Modified:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp?view=diff&rev=479490&r1=479489&r2=479490
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.cpp Sun Nov 26 17:36:58 2006
@@ -18,12 +18,14 @@
#include <activemq/core/ActiveMQSession.h>
#include <activemq/exceptions/NullPointerException.h>
+#include <activemq/util/Date.h>
using namespace std;
using namespace activemq;
using namespace activemq::core;
using namespace activemq::connector;
using namespace activemq::exceptions;
+using namespace activemq::util;
////////////////////////////////////////////////////////////////////////////////
ActiveMQProducer::ActiveMQProducer( connector::ProducerInfo* producerInfo,
@@ -41,11 +43,11 @@
this->producerInfo = producerInfo;
// Default the Delivery options
- deliveryMode = cms::DeliveryMode::PERSISTANT;
- disableMsgId = false;
- disableTimestamps = false;
- priority = 4;
- timeToLive = 0;
+ defaultDeliveryMode = cms::DeliveryMode::PERSISTANT;
+ disableMsgId = false;
+ disableTimestamps = false;
+ defaultPriority = 4;
+ defaultTimeToLive = 0;
}
////////////////////////////////////////////////////////////////////////////////
@@ -73,19 +75,61 @@
}
////////////////////////////////////////////////////////////////////////////////
+void ActiveMQProducer::send( cms::Message* message, int deliveryMode,
+ int priority,
+ long long timeToLive )
+ throw ( cms::CMSException )
+{
+ try
+ {
+ send( &producerInfo->getDestination(), message, deliveryMode,
+ priority, timeToLive );
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
void ActiveMQProducer::send( const cms::Destination* destination,
cms::Message* message) throw ( cms::CMSException )
{
try
{
+ send( destination, message, defaultDeliveryMode,
+ defaultPriority, defaultTimeToLive );
+ }
+ AMQ_CATCH_RETHROW( ActiveMQException )
+ AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ActiveMQProducer::send( const cms::Destination* destination,
+ cms::Message* message, int deliveryMode,
+ int priority, long long timeToLive)
+ throw ( cms::CMSException )
+{
+ try
+ {
// configure the message
message->setCMSDestination( destination );
message->setCMSDeliveryMode( deliveryMode );
message->setCMSPriority( priority );
- message->setCMSExpiration( timeToLive );
+
+ long long expiration = 0LL;
+
+ if( !disableTimestamps ) {
+ long long timeStamp = Date::getCurrentTimeMilliseconds();
+ message->setCMSTimeStamp(timeStamp);
+ if( timeToLive > 0LL ) {
+ expiration = timeToLive + timeStamp;
+ }
+ }
+
+ message->setCMSExpiration(expiration);
session->send( message, this );
}
AMQ_CATCH_RETHROW( ActiveMQException )
AMQ_CATCHALL_THROW( ActiveMQException )
}
+
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h?view=diff&rev=479490&r1=479489&r2=479490
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/core/ActiveMQProducer.h Sun Nov 26 17:36:58 2006
@@ -35,20 +35,20 @@
{
private:
- // Delivery Mode of this Producer
- int deliveryMode;
-
// Disable the Message Id
bool disableMsgId;
// Disable sending timestamps
bool disableTimestamps;
+
+ // The default delivery Mode of this Producer
+ int defaultDeliveryMode;
- // Priority Level to send at
- int priority;
+ // The default priority Level to send at
+ int defaultPriority;
- // Time to live setting for message
- int timeToLive;
+ // The default time to live value for messages in milliseconds
+ long long defaultTimeToLive;
// Session that this producer sends to.
ActiveMQSession* session;
@@ -64,7 +64,7 @@
ActiveMQProducer( connector::ProducerInfo* producerInfo,
ActiveMQSession* session );
- virtual ~ActiveMQProducer(void);
+ virtual ~ActiveMQProducer();
/**
* Sends the message to the default producer destination.
@@ -74,6 +74,19 @@
virtual void send( cms::Message* message ) throw ( cms::CMSException );
/**
+ * Sends the message to the default producer destination, but does
+ * not take ownership of the message, caller must still destroy it.
+ * @param message - a Message Object Pointer
+ * @param deliverMode The delivery mode to be used.
+ * @param priority The priority for this message.
+ * @param timeToLive The time to live value for this message in
+ * milliseconds.
+ * @throws CMSException
+ */
+ virtual void send( cms::Message* message, int deliveryMode, int priority,
+ long long timeToLive) throw ( cms::CMSException );
+
+ /**
* Sends the message to the designated destination.
* @param a Message Object Pointer
* @throws CMSException
@@ -81,20 +94,35 @@
virtual void send( const cms::Destination* destination,
cms::Message* message ) throw ( cms::CMSException );
+ /**
+ * Sends the message to the designated destination, but does
+ * not take ownership of the message, caller must still destroy it.
+ * @param destination - a Message Object Pointer
+ * @param message - a Message Object Pointer
+ * @param deliverMode The delivery mode to be used.
+ * @param priority The priority for this message.
+ * @param timeToLive The time to live value for this message in
+ * milliseconds.
+ * @throws CMSException
+ */
+ virtual void send( const cms::Destination* destination,
+ cms::Message* message, int deliveryMode, int priority,
+ long long timeToLive) throw ( cms::CMSException );
+
/**
* Sets the delivery mode for this Producer
* @param The DeliveryMode
*/
virtual void setDeliveryMode( int mode ) {
- deliveryMode = mode;
+ defaultDeliveryMode = mode;
}
/**
* Gets the delivery mode for this Producer
* @return The DeliveryMode
*/
- virtual int getDeliveryMode(void) const {
- return deliveryMode;
+ virtual int getDeliveryMode() const {
+ return defaultDeliveryMode;
}
/**
@@ -109,7 +137,7 @@
* Sets if Message Ids are disbled for this Producer
* @param boolean indicating enable / disable (true / false)
*/
- virtual bool getDisableMessageId(void) const {
+ virtual bool getDisableMessageId() const {
return disableMsgId;
}
@@ -125,7 +153,7 @@
* Sets if Message Time Stamps are disbled for this Producer
* @param boolean indicating enable / disable (true / false)
*/
- virtual bool getDisableMessageTimeStamp(void) const {
+ virtual bool getDisableMessageTimeStamp() const {
return disableTimestamps;
}
@@ -134,31 +162,31 @@
* @param int value for Priority level
*/
virtual void setPriority( int priority ) {
- this->priority = priority;
+ defaultPriority = priority;
}
/**
* Gets the Priority level that this producer sends messages at
* @return int based priority level
*/
- virtual int getPriority(void) const {
- return priority;
+ virtual int getPriority() const {
+ return defaultPriority;
}
/**
* Sets the Time to Live that this Producers sends messages with
- * @param int value for time to live
+ * @param time The new default time to live value in milliseconds.
*/
- virtual void setTimeToLive( int time ) {
- timeToLive = time;
+ virtual void setTimeToLive( long long time ) {
+ defaultTimeToLive = time;
}
/**
* Gets the Time to Live that this producer sends messages with
- * @return int based Time to Live
+ * @return The default time to live value in milliseconds.
*/
- virtual int getTimeToLive(void) const {
- return timeToLive;
+ virtual long long getTimeToLive() const {
+ return defaultTimeToLive;
}
public: // ActiveMQSessionResource
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h?view=diff&rev=479490&r1=479489&r2=479490
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/MessageProducer.h Sun Nov 26 17:36:58 2006
@@ -34,26 +34,56 @@
{
public:
- virtual ~MessageProducer(void) {}
+ virtual ~MessageProducer() {}
/**
* Sends the message to the default producer destination, but does
* not take ownership of the message, caller must still destroy it.
+ * Uses default values for deliveryMode, priority, and time to live.
* @param message - a Message Object Pointer
* @throws CMSException
*/
- virtual void send( Message* message ) throw ( CMSException ) = 0;
-
+ virtual void send( Message* message ) throw ( CMSException ) = 0;
+
+ /**
+ * Sends the message to the default producer destination, but does
+ * not take ownership of the message, caller must still destroy it.
+ * @param message - a Message Object Pointer
+ * @param deliverMode The delivery mode to be used.
+ * @param priority The priority for this message.
+ * @param timeToLive The time to live value for this message in
+ * milliseconds.
+ * @throws CMSException
+ */
+ virtual void send( Message* message, int deliveryMode, int priority,
+ long long timeToLive) throw ( CMSException ) = 0;
+
/**
* Sends the message to the designated destination, but does
* not take ownership of the message, caller must still destroy it.
+ * Uses default values for deliveryMode, priority, and time to live.
* @param destination - a Message Object Pointer
* @param message - the message to send to the destination
* @throws CMSException
*/
virtual void send( const Destination* destination,
Message* message ) throw ( CMSException ) = 0;
-
+
+ /**
+ * Sends the message to the designated destination, but does
+ * not take ownership of the message, caller must still destroy it.
+ * @param destination - a Message Object Pointer
+ * @param message - a Message Object Pointer
+ * @param deliverMode The delivery mode to be used.
+ * @param priority The priority for this message.
+ * @param timeToLive The time to live value for this message in
+ * milliseconds.
+ * @throws CMSException
+ */
+ virtual void send( const Destination* destination,
+ Message* message, int deliveryMode, int priority,
+ long long timeToLive) throw ( CMSException ) = 0;
+
/**
* Sets the delivery mode for this Producer
* @param mode - The DeliveryMode
@@ -64,7 +94,7 @@
* Gets the delivery mode for this Producer
* @return The DeliveryMode
*/
- virtual int getDeliveryMode(void) const = 0;
+ virtual int getDeliveryMode() const = 0;
/**
* Sets if Message Ids are disbled for this Producer
@@ -76,7 +106,7 @@
* Gets if Message Ids are disbled for this Producer
* @return boolean indicating enable / disable (true / false)
*/
- virtual bool getDisableMessageId(void) const = 0;
+ virtual bool getDisableMessageId() const = 0;
/**
* Sets if Message Time Stamps are disbled for this Producer
@@ -88,7 +118,7 @@
* Gets if Message Time Stamps are disbled for this Producer
* @return boolean indicating enable / disable (true / false)
*/
- virtual bool getDisableMessageTimeStamp(void) const = 0;
+ virtual bool getDisableMessageTimeStamp() const = 0;
/**
* Sets the Priority that this Producers sends messages at
@@ -100,19 +130,21 @@
* Gets the Priority level that this producer sends messages at
* @return int based priority level
*/
- virtual int getPriority(void) const = 0;
+ virtual int getPriority() const = 0;
/**
- * Sets the Time to Live that this Producers sends messages with
- * @param time - int value for time to live
+ * Sets the Time to Live that this Producers sends messages with. This
+ * value will be used if the time to live is not specified via the
+ * send method.
+ * @param time - default time to live value in milliseconds
*/
- virtual void setTimeToLive( int time ) = 0;
+ virtual void setTimeToLive( long long time ) = 0;
/**
* Gets the Time to Live that this producer sends messages with
- * @return int based Time to Live
+ * @return Time to live value in milliseconds
*/
- virtual int getTimeToLive(void) const = 0;
+ virtual long long getTimeToLive() const = 0;
};