summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/MessageBuilder.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2006-11-24 17:21:47 +0000
committerGordon Sim <gsim@apache.org>2006-11-24 17:21:47 +0000
commitd6befaeb77df8a09845e4c11070afe8ab4d5052d (patch)
treeb5f9ec40dedf2053d04c87f0117f0953a3026180 /cpp/src/qpid/broker/MessageBuilder.cpp
parentb442c78351bf330cf23b67e86aa17424d5a78966 (diff)
downloadqpid-python-d6befaeb77df8a09845e4c11070afe8ab4d5052d.tar.gz
Initial sketching out of staging functionality for large messages (i.e. allowing content to be stored as it arrives, rather than collecting it in memory until complete).
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@478923 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/MessageBuilder.cpp')
-rw-r--r--cpp/src/qpid/broker/MessageBuilder.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/cpp/src/qpid/broker/MessageBuilder.cpp b/cpp/src/qpid/broker/MessageBuilder.cpp
index a04c6def41..b4efd3d001 100644
--- a/cpp/src/qpid/broker/MessageBuilder.cpp
+++ b/cpp/src/qpid/broker/MessageBuilder.cpp
@@ -23,12 +23,22 @@
using namespace qpid::broker;
using namespace qpid::framing;
-MessageBuilder::MessageBuilder(CompletionHandler* _handler) : handler(_handler) {}
+MessageBuilder::MessageBuilder(CompletionHandler* _handler, MessageStore* const _store, u_int64_t _stagingThreshold) :
+ handler(_handler),
+ store(_store),
+ stagingThreshold(_stagingThreshold),
+ staging(false)
+{}
void MessageBuilder::route(){
- if(message->isComplete()){
- if(handler) handler->complete(message);
+ if (staging && store) {
+ store->stage(message);
+ message->releaseContent();
+ }
+ if (message->isComplete()) {
+ if (handler) handler->complete(message);
message.reset();
+ staging = false;
}
}
@@ -44,6 +54,7 @@ void MessageBuilder::setHeader(AMQHeaderBody::shared_ptr& header){
THROW_QPID_ERROR(PROTOCOL_ERROR + 504, "Invalid message sequence: got header before publish.");
}
message->setHeader(header);
+ staging = stagingThreshold && header->getContentSize() >= stagingThreshold;
route();
}