diff options
| author | Gordon Sim <gsim@apache.org> | 2008-04-29 20:01:33 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2008-04-29 20:01:33 +0000 |
| commit | e2c3c63774918a303ea495b3c01a1601fde78bed (patch) | |
| tree | ec2a91389821653b1270b9d8493e6e6114c961b8 /cpp/src/qpid/broker/Message.cpp | |
| parent | 9f153bc328112ed2ee25a801eff1f6a277c7bb19 (diff) | |
| download | qpid-python-e2c3c63774918a303ea495b3c01a1601fde78bed.tar.gz | |
QPID-977: shutdown mgmt client cleanly in federation tests (patch from tross@redhat.com)
QPID-981: added custom options to queue declare to tag each message as it goes through a bridge queue and allow
loop prevention through specifying exclusions
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@652075 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/Message.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/Message.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cpp/src/qpid/broker/Message.cpp b/cpp/src/qpid/broker/Message.cpp index dd013843f9..27076ccad8 100644 --- a/cpp/src/qpid/broker/Message.cpp +++ b/cpp/src/qpid/broker/Message.cpp @@ -28,6 +28,8 @@ #include "qpid/framing/SequenceNumber.h" #include "qpid/framing/TypeFilter.h" #include "qpid/log/Statement.h" +#include <boost/algorithm/string/classification.hpp> +#include <boost/algorithm/string/split.hpp> using boost::intrusive_ptr; using namespace qpid::broker; @@ -214,6 +216,7 @@ void Message::sendContent(Queue& queue, framing::FrameHandler& out, uint16_t max void Message::sendHeader(framing::FrameHandler& out, uint16_t /*maxFrameSize*/) const { + sys::Mutex::ScopedLock l(lock); Relay f(out); frames.map_if(f, TypeFilter<HEADER_BODY>()); } @@ -243,3 +246,46 @@ bool Message::isContentLoaded() const { return loaded; } + + +namespace +{ + const std::string X_QPID_TRACE("x-qpid.trace"); +} + +bool Message::isExcluded(const std::vector<std::string>& excludes) const +{ + const FieldTable* headers = getApplicationHeaders(); + if (headers) { + std::string traceStr = headers->getString(X_QPID_TRACE); + if (traceStr.size()) { + std::vector<std::string> trace; + boost::split(trace, traceStr, boost::is_any_of(", ") ); + + for (std::vector<std::string>::const_iterator i = excludes.begin(); i != excludes.end(); i++) { + for (std::vector<std::string>::const_iterator j = trace.begin(); j != trace.end(); j++) { + if (*i == *j) { + return true; + } + } + } + } + } + return false; +} + +void Message::addTraceId(const std::string& id) +{ + sys::Mutex::ScopedLock l(lock); + if (isA<MessageTransferBody>()) { + FieldTable& headers = getProperties<MessageProperties>()->getApplicationHeaders(); + std::string trace = headers.getString(X_QPID_TRACE); + if (trace.empty()) { + headers.setString(X_QPID_TRACE, id); + } else if (trace.find(id) == std::string::npos) { + trace += ","; + trace += id; + headers.setString(X_QPID_TRACE, trace); + } + } +} |
