diff options
author | David Reiss <dreiss@apache.org> | 2010-08-31 16:58:41 +0000 |
---|---|---|
committer | David Reiss <dreiss@apache.org> | 2010-08-31 16:58:41 +0000 |
commit | 9f3296bca00927ec5bac7ccdecdf2fbd68be9744 (patch) | |
tree | 8eb390cc10d98cbcc93f187d79b7d0656b80ee81 /contrib/zeromq/test-receiver.cpp | |
parent | 37b3df2c40b1ea37ef75cc58b7a635e9c6202870 (diff) | |
download | thrift-9f3296bca00927ec5bac7ccdecdf2fbd68be9744.tar.gz |
THRIFT-812. contrib: Add a demo of using Thrift over ZeroMQ
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991260 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'contrib/zeromq/test-receiver.cpp')
-rw-r--r-- | contrib/zeromq/test-receiver.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/contrib/zeromq/test-receiver.cpp b/contrib/zeromq/test-receiver.cpp new file mode 100644 index 000000000..8fe69da92 --- /dev/null +++ b/contrib/zeromq/test-receiver.cpp @@ -0,0 +1,40 @@ +#include "zmq.hpp" +#include "TZmqServer.h" +#include "Storage.h" + +using boost::shared_ptr; +using apache::thrift::TProcessor; +using apache::thrift::server::TZmqServer; +using apache::thrift::server::TZmqMultiServer; + +class StorageHandler : virtual public StorageIf { + public: + StorageHandler() + : value_(0) + {} + + void incr(const int32_t amount) { + value_ += amount; + printf("value_: %i\n", value_) ; + } + + int32_t get() { + return value_; + } + + private: + int32_t value_; + +}; + + +int main(int argc, char *argv[]) { + shared_ptr<StorageHandler> handler(new StorageHandler()); + shared_ptr<TProcessor> processor(new StorageProcessor(handler)); + + zmq::context_t ctx(1); + TZmqServer oneway_server(processor, ctx, "epgm://eth0;239.192.1.1:5555", ZMQ_SUB); + oneway_server.serve(); + + return 0; +} |