summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2009-06-09 12:41:53 +0000
committerGordon Sim <gsim@apache.org>2009-06-09 12:41:53 +0000
commit48d3b387dd4fcbdda84f32a4a2f84da67d09ea9f (patch)
treef6c7ce357c255fbf6c8750c8e3d4fa728a2c1bef
parent1c81b58b55074bc233c2d887ce77576ef075a0d1 (diff)
downloadqpid-python-48d3b387dd4fcbdda84f32a4a2f84da67d09ea9f.tar.gz
Enhanced test sender to allow the lvq match keys used to be specified in a file.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@782978 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/tests/sender.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/qpid/cpp/src/tests/sender.cpp b/qpid/cpp/src/tests/sender.cpp
index 9d9e5be99d..311de2e5f8 100644
--- a/qpid/cpp/src/tests/sender.cpp
+++ b/qpid/cpp/src/tests/sender.cpp
@@ -28,6 +28,7 @@
#include <qpid/Exception.h>
#include "TestOptions.h"
+#include <fstream>
#include <iostream>
using namespace qpid;
@@ -43,6 +44,7 @@ struct Args : public qpid::TestOptions
uint sendEos;
bool durable;
string lvqMatchValue;
+ string lvqMatchFile;
Args() : key("test-queue"), sendEos(0), durable(false)
{
@@ -51,7 +53,8 @@ struct Args : public qpid::TestOptions
("routing-key", qpid::optValue(key, "KEY"), "Routing key to add to messages")
("send-eos", qpid::optValue(sendEos, "N"), "Send N EOS messages to mark end of input")
("durable", qpid::optValue(durable, "true|false"), "Mark messages as durable.")
- ("lvq-match-value", qpid::optValue(lvqMatchValue, "KEY"), "The value to set for the LVQ match key property");
+ ("lvq-match-value", qpid::optValue(lvqMatchValue, "KEY"), "The value to set for the LVQ match key property")
+ ("lvq-match-file", qpid::optValue(lvqMatchFile, "FILE"), "A file containing values to set for the LVQ match key property");
}
};
@@ -60,7 +63,8 @@ const string EOS("eos");
class Sender : public FailoverManager::Command
{
public:
- Sender(const std::string& destination, const std::string& key, uint sendEos, bool durable, const std::string& lvqMatchValue);
+ Sender(const std::string& destination, const std::string& key, uint sendEos, bool durable,
+ const std::string& lvqMatchValue, const std::string& lvqMatchFile);
void execute(AsyncSession& session, bool isRetry);
private:
const std::string destination;
@@ -68,10 +72,12 @@ class Sender : public FailoverManager::Command
Message message;
const uint sendEos;
uint sent;
+ std::ifstream lvqMatchValues;
};
-Sender::Sender(const std::string& dest, const std::string& key, uint eos, bool durable, const std::string& lvqMatchValue) :
- destination(dest), sender(10), message("", key), sendEos(eos), sent(0)
+Sender::Sender(const std::string& dest, const std::string& key, uint eos, bool durable,
+ const std::string& lvqMatchValue, const std::string& lvqMatchFile) :
+ destination(dest), sender(10), message("", key), sendEos(eos), sent(0) , lvqMatchValues(lvqMatchFile.c_str())
{
if (durable){
message.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
@@ -90,6 +96,10 @@ void Sender::execute(AsyncSession& session, bool isRetry)
while (getline(std::cin, data)) {
message.setData(data);
message.getHeaders().setInt("sn", ++sent);
+ string matchKey;
+ if (lvqMatchValues && getline(lvqMatchValues, matchKey)) {
+ message.getHeaders().setString(QueueOptions::strLVQMatchProperty, matchKey);
+ }
sender.send(message, destination);
}
for (uint i = sendEos; i > 0; --i) {
@@ -104,7 +114,7 @@ int main(int argc, char ** argv)
try {
opts.parse(argc, argv);
FailoverManager connection(opts.con);
- Sender sender(opts.destination, opts.key, opts.sendEos, opts.durable, opts.lvqMatchValue);
+ Sender sender(opts.destination, opts.key, opts.sendEos, opts.durable, opts.lvqMatchValue, opts.lvqMatchFile);
connection.execute(sender);
connection.close();
return 0;