summaryrefslogtreecommitdiff
path: root/cpp/src/qpid
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2010-02-15 18:36:21 +0000
committerKim van der Riet <kpvdr@apache.org>2010-02-15 18:36:21 +0000
commitdef38493b7c9ac3766d60e0cdd334bb1db7f6139 (patch)
tree34b7ea764ad0bf24dcaffcef1c7e67a5135cba08 /cpp/src/qpid
parent18ab7b99112de6c137285da1f147efbe6fca3216 (diff)
downloadqpid-python-def38493b7c9ac3766d60e0cdd334bb1db7f6139.tar.gz
Added handling for adjusting TTL on outgoing message based on how long a message has been on the queue. Added a new TTL test as ClientSessionTest.testTtl.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@910289 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
-rw-r--r--cpp/src/qpid/broker/DeliveryRecord.cpp1
-rw-r--r--cpp/src/qpid/broker/Message.cpp10
-rw-r--r--cpp/src/qpid/broker/Message.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/cpp/src/qpid/broker/DeliveryRecord.cpp b/cpp/src/qpid/broker/DeliveryRecord.cpp
index 22ec5e86a0..64db84b6ec 100644
--- a/cpp/src/qpid/broker/DeliveryRecord.cpp
+++ b/cpp/src/qpid/broker/DeliveryRecord.cpp
@@ -76,6 +76,7 @@ void DeliveryRecord::deliver(framing::FrameHandler& h, DeliveryId deliveryId, ui
if (msg.payload->getRedelivered()){
msg.payload->getProperties<framing::DeliveryProperties>()->setRedelivered(true);
}
+ msg.payload->adjustTtl();
framing::AMQFrame method((framing::MessageTransferBody(framing::ProtocolVersion(), tag, acceptExpected ? 0 : 1, acquired ? 0 : 1)));
method.setEof(false);
diff --git a/cpp/src/qpid/broker/Message.cpp b/cpp/src/qpid/broker/Message.cpp
index 58de0cc9dc..ff4a37c88f 100644
--- a/cpp/src/qpid/broker/Message.cpp
+++ b/cpp/src/qpid/broker/Message.cpp
@@ -361,6 +361,16 @@ void Message::setTimestamp(const boost::intrusive_ptr<ExpiryPolicy>& e)
}
}
+void Message::adjustTtl()
+{
+ DeliveryProperties* props = getProperties<DeliveryProperties>();
+ if (props->getTtl()) {
+ sys::Mutex::ScopedLock l(lock);
+ sys::Duration d(sys::AbsTime::now(), getExpiration());
+ props->setTtl(int64_t(d) > 0 ? int64_t(d)/1000000 : 1); // convert from ns to ms; set to 1 if expired
+ }
+}
+
void Message::setExpiryPolicy(const boost::intrusive_ptr<ExpiryPolicy>& e) {
expiryPolicy = e;
if (expiryPolicy)
diff --git a/cpp/src/qpid/broker/Message.h b/cpp/src/qpid/broker/Message.h
index becde0f872..0a7772040b 100644
--- a/cpp/src/qpid/broker/Message.h
+++ b/cpp/src/qpid/broker/Message.h
@@ -81,6 +81,7 @@ public:
void setExpiryPolicy(const boost::intrusive_ptr<ExpiryPolicy>& e);
bool hasExpired();
sys::AbsTime getExpiration() const { return expiration; }
+ void adjustTtl();
framing::FrameSet& getFrames() { return frames; }
const framing::FrameSet& getFrames() const { return frames; }