diff options
author | Alan Conway <aconway@apache.org> | 2008-06-09 20:55:09 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-06-09 20:55:09 +0000 |
commit | 03a39d920d010b29b156a99ee9b3fcfc7c7c64a1 (patch) | |
tree | 0959d63de389bd08fcb5d074eb5a0712a1db24a8 /cpp | |
parent | 31a74cd4a5c849b134a172cc5e6ce2e2a447e5e5 (diff) | |
download | qpid-python-03a39d920d010b29b156a99ee9b3fcfc7c7c64a1.tar.gz |
Updated doxygen comments in qpid/client/*.h
Changed request-response example to use SubscriptionManager like the others.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@665891 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
36 files changed, 270 insertions, 571 deletions
diff --git a/cpp/docs/api/user.doxygen.in b/cpp/docs/api/user.doxygen.in index 4b65b73347..ee0860f8b4 100644 --- a/cpp/docs/api/user.doxygen.in +++ b/cpp/docs/api/user.doxygen.in @@ -249,7 +249,7 @@ EXTRACT_LOCAL_CLASSES = NO # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. -EXTRACT_LOCAL_METHODS = YES +EXTRACT_LOCAL_METHODS = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. @@ -457,7 +457,7 @@ WARN_LOGFILE = doxygen.log # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @abs_top_srcdir@/src @abs_top_builddir@/src/gen +INPUT = @top_srcdir@/src/qpid @top_builddir@/src/gen/qpid # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp @@ -477,7 +477,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = test +EXCLUDE = test tests broker amqp_0_10 log sys cluster management # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -553,7 +553,7 @@ FILTER_SOURCE_FILES = NO # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. -SOURCE_BROWSER = NO +SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. @@ -590,7 +590,7 @@ USE_HTAGS = NO # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. -VERBATIM_HEADERS = YES +VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index diff --git a/cpp/examples/examples/direct/listener.cpp b/cpp/examples/examples/direct/listener.cpp index fc2fa96ead..b1aa9754bc 100644 --- a/cpp/examples/examples/direct/listener.cpp +++ b/cpp/examples/examples/direct/listener.cpp @@ -24,7 +24,6 @@ * the broker using a message listener. */ -#include <qpid/client/Dispatcher.h> #include <qpid/client/Connection.h> #include <qpid/client/Session.h> #include <qpid/client/Message.h> diff --git a/cpp/examples/examples/fanout/listener.cpp b/cpp/examples/examples/fanout/listener.cpp index d9bf9789dc..294dfc7855 100644 --- a/cpp/examples/examples/fanout/listener.cpp +++ b/cpp/examples/examples/fanout/listener.cpp @@ -24,7 +24,6 @@ * the broker using a message listener. */ -#include <qpid/client/Dispatcher.h> #include <qpid/client/Connection.h> #include <qpid/client/Session.h> #include <qpid/client/Message.h> diff --git a/cpp/examples/examples/pub-sub/topic_listener.cpp b/cpp/examples/examples/pub-sub/topic_listener.cpp index 4d854e57ff..9996abab19 100644 --- a/cpp/examples/examples/pub-sub/topic_listener.cpp +++ b/cpp/examples/examples/pub-sub/topic_listener.cpp @@ -44,7 +44,6 @@ #include <qpid/client/Session.h> #include <qpid/client/Message.h> #include <qpid/client/MessageListener.h> -#include <qpid/client/Queue.h> #include <qpid/client/SubscriptionManager.h> #include <unistd.h> diff --git a/cpp/examples/examples/request-response/client.cpp b/cpp/examples/examples/request-response/client.cpp index 79bc88c6ae..0ee0e78c92 100644 --- a/cpp/examples/examples/request-response/client.cpp +++ b/cpp/examples/examples/request-response/client.cpp @@ -39,7 +39,7 @@ #include <qpid/client/Connection.h> -#include <qpid/client/Dispatcher.h> +#include <qpid/client/SubscriptionManager.h> #include <qpid/client/Session.h> #include <qpid/client/Message.h> #include <qpid/client/MessageListener.h> @@ -54,53 +54,25 @@ using namespace qpid::client; using namespace qpid::framing; class Listener : public MessageListener{ -private: - Session session; - std::string destination_name; - Dispatcher dispatcher; - int counter; -public: - Listener(Session& session, string destination_name): - session(session), - destination_name(destination_name), - dispatcher(session), - counter(0) - {}; - - virtual void listen(); - virtual void wait(); - virtual void received(Message& message); - ~Listener() { }; + private: + SubscriptionManager& subscriptions; + int counter; + public: + Listener(SubscriptionManager& subscriptions); + virtual void received(Message& message); }; - -void Listener::listen() { - std::cout << "Activating response queue listener for: " <<destination_name << std::endl; - - session.messageSubscribe(arg::queue=destination_name, arg::destination=destination_name); - - session.messageFlow(arg::destination=destination_name, arg::unit=MESSAGE_CREDIT, arg::value=1); - session.messageFlow(arg::destination=destination_name, arg::unit=BYTE_CREDIT, arg::value=UNLIMITED_CREDIT); - - - dispatcher.listen(destination_name, this); -} - - -void Listener::wait() { - std::cout << "Waiting for all responses to arrive ..." << std::endl; - dispatcher.run(); -} - +Listener::Listener(SubscriptionManager& subs) : subscriptions(subs), counter(0) +{} void Listener::received(Message& message) { - std::cout << "Response: " << message.getData() << std::endl; + std::cout << "Response: " << message.getData() << std::endl; - ++ counter; - if (counter > 3) { - std::cout << "Shutting down listener for " << destination_name << std::endl; - dispatcher.stop(); - } + ++ counter; + if (counter > 3) { + std::cout << "Shutting down listener for " << message.getDestination() << std::endl; + subscriptions.cancel(message.getDestination()); + } } @@ -116,7 +88,7 @@ int main(int argc, char** argv) { connection.open(host, port); Session session = connection.newSession(); - //--------- Main body of program -------------------------------------------- + //--------- Main body of program -------------------------------------------- // Create a response queue so the server can send us responses // to our requests. Use the client's session ID as the name @@ -130,45 +102,40 @@ int main(int argc, char** argv) { session.queueDeclare(arg::queue=response_queue.str()); session.exchangeBind(arg::exchange="amq.direct", arg::queue=response_queue.str(), arg::bindingKey=response_queue.str()); - // Create a listener for the response queue and start listening. - - Listener listener(session, response_queue.str()); - listener.listen(); - - - // The routing key for the request queue is simply - // "request", and all clients use the same routing key. - // // Each client sends the name of their own response queue so // the service knows where to route messages. request.getDeliveryProperties().setRoutingKey("request"); request.getMessageProperties().setReplyTo(ReplyTo("amq.direct", response_queue.str())); + // Create a listener for the response queue and listen for response messages. + std::cout << "Activating response queue listener for: " << response_queue.str() << std::endl; + SubscriptionManager subscriptions(session); + Listener listener(subscriptions); + subscriptions.subscribe(listener, response_queue.str()); + // Now send some requests ... string s[] = { - "Twas brillig, and the slithy toves", - "Did gire and gymble in the wabe.", - "All mimsy were the borogroves,", - "And the mome raths outgrabe." + "Twas brillig, and the slithy toves", + "Did gire and gymble in the wabe.", + "All mimsy were the borogroves,", + "And the mome raths outgrabe." }; for (int i=0; i<4; i++) { - request.setData(s[i]); - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=request, arg::destination="amq.direct"); - std::cout << "Request: " << s[i] << std::endl; + request.setData(s[i]); + // Asynchronous transfer sends messages as quickly as + // possible without waiting for confirmation. + async(session).messageTransfer(arg::content=request, arg::destination="amq.direct"); + std::cout << "Request: " << s[i] << std::endl; } - // And wait for any outstanding responses to arrive - - listener.wait(); - + std::cout << "Waiting for all responses to arrive ..." << std::endl; + subscriptions.run(); - //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- connection.close(); return 0; diff --git a/cpp/examples/examples/request-response/server.cpp b/cpp/examples/examples/request-response/server.cpp index 83144c715d..df189cfdd8 100644 --- a/cpp/examples/examples/request-response/server.cpp +++ b/cpp/examples/examples/request-response/server.cpp @@ -39,8 +39,9 @@ #include <qpid/client/Connection.h> -#include <qpid/client/Dispatcher.h> +#include <qpid/client/SubscriptionManager.h> #include <qpid/client/Session.h> +#include <qpid/client/AsyncSession.h> #include <qpid/client/Message.h> #include <qpid/client/MessageListener.h> @@ -59,102 +60,79 @@ using std::stringstream; using std::string; class Listener : public MessageListener{ -private: - std::string destination_name; - Dispatcher dispatcher; - Session session; -public: - Listener(Session& session, string destination_name): - destination_name(destination_name), - dispatcher(session), - session(session) - {}; - - virtual void listen(); - virtual void received(Message& message); - virtual void wait(); - ~Listener() { }; + private: + SubscriptionManager& subscriptions; + AsyncSession asyncSession; + public: + Listener(SubscriptionManager& subscriptions, Session& session); + virtual void received(Message& message); }; - -void Listener::listen() { - std::cout << "Activating request queue listener for: " <<destination_name << std::endl; - - session.messageSubscribe(arg::queue=destination_name, arg::destination=destination_name); - - session.messageFlow(arg::destination=destination_name, arg::unit=MESSAGE_CREDIT, arg::value=1); - session.messageFlow(arg::destination=destination_name, arg::unit=BYTE_CREDIT, arg::value=UNLIMITED_CREDIT); - - dispatcher.listen(destination_name, this); -} - - -void Listener::wait() { - std::cout << "Waiting for requests" << std::endl; - dispatcher.run(); -} - +Listener::Listener(SubscriptionManager& subs, Session& session) + : subscriptions(subs), asyncSession(session) +{} void Listener::received(Message& request) { + Message response; - Message response; - - // Get routing key for response from the request's replyTo property + // Get routing key for response from the request's replyTo property + string routingKey; - string routingKey; + if (request.getMessageProperties().hasReplyTo()) { + routingKey = request.getMessageProperties().getReplyTo().getRoutingKey(); + } else { + std::cout << "Error: " << "No routing key for request (" << request.getData() << ")" << std::endl; + return; + } - if (request.getMessageProperties().hasReplyTo()) { - routingKey = request.getMessageProperties().getReplyTo().getRoutingKey(); - } else { - std::cout << "Error: " << "No routing key for request (" << request.getData() << ")" << std::endl; - return; - } + std::cout << "Request: " << request.getData() << " (" <<routingKey << ")" << std::endl; - std::cout << "Request: " << request.getData() << " (" <<routingKey << ")" << std::endl; + // Transform message content to upper case + std::string s = request.getData(); + std::transform (s.begin(), s.end(), s.begin(), toupper); + response.setData(s); - // Transform message content to upper case - std::string s = request.getData(); - std::transform (s.begin(), s.end(), s.begin(), toupper); - response.setData(s); + // Send it back to the user + response.getDeliveryProperties().setRoutingKey(routingKey); - // Send it back to the user - response.getDeliveryProperties().setRoutingKey(routingKey); - - // Asynchronous transfer sends messages as quickly as - // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=response, arg::destination="amq.direct"); + // Asynchronous transfer sends messages as quickly as + // possible without waiting for confirmation. + asyncSession.messageTransfer(arg::content=response, arg::destination="amq.direct"); } int main(int argc, char** argv) { const char* host = argc>1 ? argv[1] : "127.0.0.1"; int port = argc>2 ? atoi(argv[2]) : 5672; - Connection connection; + Connection connection; Message message; try { connection.open(host, port); Session session = connection.newSession(); - //--------- Main body of program -------------------------------------------- + //--------- Main body of program -------------------------------------------- + // Create a request queue for clients to use when making // requests. - string request_queue = "request"; // Use the name of the request queue as the routing key - session.queueDeclare(arg::queue=request_queue); session.exchangeBind(arg::exchange="amq.direct", arg::queue=request_queue, arg::bindingKey=request_queue); - // Create a listener for the request queue and start listening. - - Listener listener(session, request_queue); - listener.listen(); - listener.wait(); + // Create a listener and subscribe it to the request_queue + std::cout << "Activating request queue listener for: " << request_queue << std::endl; + SubscriptionManager subscriptions(session); + Listener listener(subscriptions, session); + subscriptions.subscribe(listener, request_queue); + // Deliver messages until the subscription is cancelled + // by Listener::received() + std::cout << "Waiting for requests" << std::endl; + subscriptions.run(); - //----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- connection.close(); return 0; diff --git a/cpp/examples/examples/xml-exchange/listener.cpp b/cpp/examples/examples/xml-exchange/listener.cpp index 559cfaf8c9..f4305b5c5a 100644 --- a/cpp/examples/examples/xml-exchange/listener.cpp +++ b/cpp/examples/examples/xml-exchange/listener.cpp @@ -24,7 +24,6 @@ * the broker using a message listener. */ -#include <qpid/client/Dispatcher.h> #include <qpid/client/Connection.h> #include <qpid/client/Session.h> #include <qpid/client/Message.h> diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index d498b1f60e..cc594b0f3b 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -321,14 +321,12 @@ libqpidclient_la_SOURCES = \ qpid/client/ConnectionSettings.cpp \ qpid/client/Demux.cpp \ qpid/client/Dispatcher.cpp \ - qpid/client/Exchange.cpp \ qpid/client/Future.cpp \ qpid/client/FutureCompletion.cpp \ qpid/client/FutureResult.cpp \ qpid/client/LocalQueue.cpp \ qpid/client/Message.cpp \ qpid/client/MessageListener.cpp \ - qpid/client/Queue.cpp \ qpid/client/Results.cpp \ qpid/client/SessionBase_0_10.cpp \ qpid/client/SessionBase_0_10.h \ @@ -444,7 +442,6 @@ nobase_include_HEADERS = \ qpid/client/ChainableFrameHandler.h \ qpid/client/Demux.h \ qpid/client/Dispatcher.h \ - qpid/client/Exchange.h \ qpid/client/Execution.h \ qpid/client/Future.h \ qpid/client/FutureCompletion.h \ @@ -453,7 +450,6 @@ nobase_include_HEADERS = \ qpid/client/Message.h \ qpid/client/MessageListener.h \ qpid/client/MessageQueue.h \ - qpid/client/Queue.h \ qpid/client/Results.h \ qpid/client/SessionBase_0_10.h \ qpid/client/Session.h \ diff --git a/cpp/src/qpid/client/AckPolicy.h b/cpp/src/qpid/client/AckPolicy.h index 2faa600556..b34f1d15d1 100644 --- a/cpp/src/qpid/client/AckPolicy.h +++ b/cpp/src/qpid/client/AckPolicy.h @@ -30,6 +30,7 @@ namespace client { /** * Policy for automatic acknowledgement of messages. + * * * \ingroup clientapi */ diff --git a/cpp/src/qpid/client/Completion.h b/cpp/src/qpid/client/Completion.h index 22cc70607a..c4979d7934 100644 --- a/cpp/src/qpid/client/Completion.h +++ b/cpp/src/qpid/client/Completion.h @@ -30,9 +30,13 @@ namespace qpid { namespace client { /** - * Returned by asynchronous commands that do not return any result. - * You can use this to wait for an individual command to complete. - * \clientapi + * Asynchronous commands that do not return a result will return a + * Completion. You can use the completion to wait for that specific + * command to complete. + * + *@see TypedResult + * + *\ingroup clientapi */ class Completion { @@ -41,11 +45,17 @@ protected: shared_ptr<SessionImpl> session; public: + ///@internal Completion() {} + ///@internal Completion(Future f, shared_ptr<SessionImpl> s) : future(f), session(s) {} - /** Wait for the command to complete */ + /** Wait for the asynchronous command that returned this + *Completion to complete. + * + *@exception If the command returns an error, get() throws an exception. + */ void wait() { future.wait(*session); diff --git a/cpp/src/qpid/client/Connection.cpp b/cpp/src/qpid/client/Connection.cpp index 752cb9095c..6572794516 100644 --- a/cpp/src/qpid/client/Connection.cpp +++ b/cpp/src/qpid/client/Connection.cpp @@ -27,6 +27,7 @@ #include "qpid/log/Options.h" #include "qpid/log/Statement.h" #include "qpid/shared_ptr.h" +#include "qpid/framing/AMQP_HighestVersion.h" #include <algorithm> #include <iostream> @@ -42,8 +43,7 @@ using namespace qpid::sys; namespace qpid { namespace client { -Connection::Connection(framing::ProtocolVersion _version) : - channelIdCounter(0), version(_version) {} +Connection::Connection() : channelIdCounter(0), version(framing::highestProtocolVersion) {} Connection::~Connection(){ } diff --git a/cpp/src/qpid/client/Connection.h b/cpp/src/qpid/client/Connection.h index 81a7ffa008..a476f2d880 100644 --- a/cpp/src/qpid/client/Connection.h +++ b/cpp/src/qpid/client/Connection.h @@ -25,27 +25,16 @@ #include <string> #include "ConnectionImpl.h" #include "qpid/client/Session.h" -#include "qpid/framing/AMQP_HighestVersion.h" namespace qpid { - -/** - * The client namespace contains all classes that make up a client - * implementation of the AMQP protocol. The key classes that form - * the basis of the client API to be used by applications are - * Connection and Channel. - */ namespace client { class ConnectionSettings; -/** - * \defgroup clientapi Application API for an AMQP client. - */ /** * Represents a connection to an AMQP broker. All communication is - * initiated by establishing a connection, then opening one or - * more Channels over that connection. + * initiated by establishing a connection, then creating one or more + * Session objecst using the connection. @see newSession() * * \ingroup clientapi */ @@ -60,12 +49,10 @@ class Connection public: /** - * Creates a connection object, but does not open the - * connection. - * - * @param _version the version of the protocol to connect with. + * Creates a connection object, but does not open the connection. + * @see open() */ - Connection(framing::ProtocolVersion=framing::highestProtocolVersion); + Connection(); ~Connection(); /** diff --git a/cpp/src/qpid/client/Connector.h b/cpp/src/qpid/client/Connector.h index f5628b9bcc..b35e77c726 100644 --- a/cpp/src/qpid/client/Connector.h +++ b/cpp/src/qpid/client/Connector.h @@ -48,6 +48,7 @@ class Bounds; class ConnectionSettings; class ConnectionImpl; +///@internal class Connector : public framing::OutputHandler, private sys::Runnable { diff --git a/cpp/src/qpid/client/Demux.h b/cpp/src/qpid/client/Demux.h index dce24223f2..5c640f99d2 100644 --- a/cpp/src/qpid/client/Demux.h +++ b/cpp/src/qpid/client/Demux.h @@ -32,6 +32,7 @@ namespace qpid { namespace client { +///@internal class ByTransferDest { const std::string dest; @@ -40,6 +41,7 @@ public: bool operator()(const framing::FrameSet& frameset) const; }; +///@internal class Demux { public: diff --git a/cpp/src/qpid/client/Dispatcher.h b/cpp/src/qpid/client/Dispatcher.h index 1b31ddf4cf..7d42bf8793 100644 --- a/cpp/src/qpid/client/Dispatcher.h +++ b/cpp/src/qpid/client/Dispatcher.h @@ -35,6 +35,7 @@ namespace qpid { namespace client { +///@internal class Subscriber : public MessageListener { AsyncSession session; @@ -48,8 +49,10 @@ public: }; +///@internal typedef framing::Handler<framing::FrameSet> FrameSetHandler; +///@internal class Dispatcher : public sys::Runnable { typedef std::map<std::string, Subscriber::shared_ptr> Listeners; diff --git a/cpp/src/qpid/client/Exchange.cpp b/cpp/src/qpid/client/Exchange.cpp deleted file mode 100644 index e7fbdeb47e..0000000000 --- a/cpp/src/qpid/client/Exchange.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "Exchange.h" - -qpid::client::Exchange::Exchange(std::string _name, std::string _type) : name(_name), type(_type){} -const std::string& qpid::client::Exchange::getName() const { return name; } -const std::string& qpid::client::Exchange::getType() const { return type; } - -const std::string qpid::client::Exchange::DIRECT_EXCHANGE = "direct"; -const std::string qpid::client::Exchange::TOPIC_EXCHANGE = "topic"; -const std::string qpid::client::Exchange::HEADERS_EXCHANGE = "headers"; - -const qpid::client::Exchange qpid::client::Exchange::DEFAULT_EXCHANGE("", DIRECT_EXCHANGE); -const qpid::client::Exchange qpid::client::Exchange::STANDARD_DIRECT_EXCHANGE("amq.direct", DIRECT_EXCHANGE); -const qpid::client::Exchange qpid::client::Exchange::STANDARD_TOPIC_EXCHANGE("amq.topic", TOPIC_EXCHANGE); -const qpid::client::Exchange qpid::client::Exchange::STANDARD_HEADERS_EXCHANGE("amq.headers", HEADERS_EXCHANGE); diff --git a/cpp/src/qpid/client/Exchange.h b/cpp/src/qpid/client/Exchange.h deleted file mode 100644 index f30881c94b..0000000000 --- a/cpp/src/qpid/client/Exchange.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include <string> - -#ifndef _Exchange_ -#define _Exchange_ - -namespace qpid { -namespace client { - - /** - * DEPRECATED - * - * A 'handle' used to represent an AMQP exchange in the Channel - * methods. Exchanges are the destinations to which messages are - * published. - * - * There are different types of exchange (the standard types are - * available as static constants, see DIRECT_EXCHANGE, - * TOPIC_EXCHANGE and HEADERS_EXCHANGE). A Queue can be bound to - * an exchange using Channel::bind() and messages published to - * that exchange are then routed to the queue based on the details - * of the binding and the type of exchange. - * - * There are some standard exchange instances that are predeclared - * on all AMQP brokers. These are defined as static members - * STANDARD_DIRECT_EXCHANGE, STANDARD_TOPIC_EXCHANGE and - * STANDARD_HEADERS_EXCHANGE. There is also the 'default' exchange - * (member DEFAULT_EXCHANGE) which is nameless and of type - * 'direct' and has every declared queue bound to it by queue - * name. - */ - class Exchange{ - const std::string name; - const std::string type; - - public: - /** - * A direct exchange routes messages published with routing - * key X to any queue bound with key X (i.e. an exact match is - * used). - */ - static const std::string DIRECT_EXCHANGE; - /** - * A topic exchange treats the key with which a queue is bound - * as a pattern and routes all messages whose routing keys - * match that pattern to the bound queue. The routing key for - * a message must consist of zero or more alpha-numeric words - * delimited by dots. The pattern is of a similar form, but * - * can be used to match exactly one word and # can be used to - * match zero or more words. - */ - static const std::string TOPIC_EXCHANGE; - - /** - * - */ - - static const std::string XML_EXCHANGE; - - /** - * The headers exchange routes messages based on whether their - * headers match the binding arguments specified when - * binding. (see the AMQP spec for more details). - */ - static const std::string HEADERS_EXCHANGE; - - /** - * The 'default' exchange, nameless and of type 'direct', has - * every declared queue bound to it by name. - */ - static const Exchange DEFAULT_EXCHANGE; - /** - * The standard direct exchange, named amq.direct. - */ - static const Exchange STANDARD_DIRECT_EXCHANGE; - /** - * The standard topic exchange, named amq.topic. - */ - static const Exchange STANDARD_TOPIC_EXCHANGE; - /** - * The standard headers exchange, named amq.header. - */ - static const Exchange STANDARD_HEADERS_EXCHANGE; - - Exchange(std::string name, std::string type = DIRECT_EXCHANGE); - const std::string& getName() const; - const std::string& getType() const; - }; - -} -} - - -#endif diff --git a/cpp/src/qpid/client/Execution.h b/cpp/src/qpid/client/Execution.h index b8c8a4292d..10674afde0 100644 --- a/cpp/src/qpid/client/Execution.h +++ b/cpp/src/qpid/client/Execution.h @@ -27,7 +27,8 @@ namespace qpid { namespace client { -/** +/**@internal + * * Provides access to more detailed aspects of the session * implementation. */ diff --git a/cpp/src/qpid/client/Future.h b/cpp/src/qpid/client/Future.h index faf68c9104..67f39cdf3f 100644 --- a/cpp/src/qpid/client/Future.h +++ b/cpp/src/qpid/client/Future.h @@ -34,6 +34,7 @@ namespace qpid { namespace client { +/**@internal */ class Future : private framing::StructHelper { framing::SequenceNumber command; diff --git a/cpp/src/qpid/client/FutureCompletion.h b/cpp/src/qpid/client/FutureCompletion.h index 1897230230..4248ddeab8 100644 --- a/cpp/src/qpid/client/FutureCompletion.h +++ b/cpp/src/qpid/client/FutureCompletion.h @@ -28,6 +28,7 @@ namespace qpid { namespace client { +///@internal class FutureCompletion { protected: diff --git a/cpp/src/qpid/client/FutureResult.h b/cpp/src/qpid/client/FutureResult.h index f889706493..e97d80476d 100644 --- a/cpp/src/qpid/client/FutureResult.h +++ b/cpp/src/qpid/client/FutureResult.h @@ -31,6 +31,7 @@ namespace client { class SessionImpl; +///@internal class FutureResult : public FutureCompletion { std::string result; diff --git a/cpp/src/qpid/client/LocalQueue.h b/cpp/src/qpid/client/LocalQueue.h index 58887077f6..c76d0756eb 100644 --- a/cpp/src/qpid/client/LocalQueue.h +++ b/cpp/src/qpid/client/LocalQueue.h @@ -30,23 +30,45 @@ namespace qpid { namespace client { /** - * Local representation of a remote queue. + * A local queue to collect messages retrieved from a remote broker + * queue. Create a queue and subscribe it using the SubscriptionManager. + * Messages from the remote queue on the broker will be stored in the + * local queue until you retrieve them. * * \ingroup clientapi */ class LocalQueue { public: - LocalQueue(AckPolicy=AckPolicy()); + /** Create a local queue. Subscribe the local queue to a remote broker + * queue with a SubscriptionManager. + * + * LocalQueue is an alternative to implementing a MessageListener. + * + *@param ackPolicy Policy for acknowledging messages. @see AckPolicy. + */ + LocalQueue(AckPolicy ackPolicy=AckPolicy()); + ~LocalQueue(); - /** Pop the next message off the queue. + /** Pop the next message off the local queue. *@exception ClosedException if subscription has been closed. */ Message pop(); + + /** Synonym for get(). */ + Message get() { return pop(); } + + /** Return true if local queue is empty. */ bool empty() const; + + /** Number of messages on the local queue */ size_t size() const; + + /** Set the message acknowledgement policy. @see AckPolicy. */ void setAckPolicy(AckPolicy); + + /** Get the message acknowledgement policy. @see AckPolicy. */ AckPolicy& getAckPolicy(); private: diff --git a/cpp/src/qpid/client/Message.cpp b/cpp/src/qpid/client/Message.cpp index 58d8fb142a..d5464594ee 100644 --- a/cpp/src/qpid/client/Message.cpp +++ b/cpp/src/qpid/client/Message.cpp @@ -24,45 +24,50 @@ namespace qpid { namespace client { - Message::Message(const std::string& data_, - const std::string& routingKey, - const std::string& exchange) : TransferContent(data_, routingKey, exchange) {} +Message::Message(const std::string& data_, + const std::string& routingKey, + const std::string& exchange) : TransferContent(data_, routingKey, exchange) {} - std::string Message::getDestination() const - { - return method.getDestination(); - } +std::string Message::getDestination() const +{ + return method.getDestination(); +} - bool Message::isRedelivered() const - { - return hasDeliveryProperties() && getDeliveryProperties().getRedelivered(); - } +bool Message::isRedelivered() const +{ + return hasDeliveryProperties() && getDeliveryProperties().getRedelivered(); +} - void Message::setRedelivered(bool redelivered) - { - getDeliveryProperties().setRedelivered(redelivered); - } +void Message::setRedelivered(bool redelivered) +{ + getDeliveryProperties().setRedelivered(redelivered); +} - framing::FieldTable& Message::getHeaders() - { - return getMessageProperties().getApplicationHeaders(); - } +framing::FieldTable& Message::getHeaders() +{ + return getMessageProperties().getApplicationHeaders(); +} - const framing::MessageTransferBody& Message::getMethod() const - { - return method; - } +const framing::FieldTable& Message::getHeaders() const +{ + return getMessageProperties().getApplicationHeaders(); +} - const framing::SequenceNumber& Message::getId() const - { - return id; - } +const framing::MessageTransferBody& Message::getMethod() const +{ + return method; +} - /**@internal for incoming messages */ - Message::Message(const framing::FrameSet& frameset) : - method(*frameset.as<framing::MessageTransferBody>()), id(frameset.getId()) - { - populate(frameset); - } +const framing::SequenceNumber& Message::getId() const +{ + return id; +} + +/**@internal for incoming messages */ +Message::Message(const framing::FrameSet& frameset) : + method(*frameset.as<framing::MessageTransferBody>()), id(frameset.getId()) +{ + populate(frameset); +} }} diff --git a/cpp/src/qpid/client/Message.h b/cpp/src/qpid/client/Message.h index 3c22d202ee..4e6ed49bb4 100644 --- a/cpp/src/qpid/client/Message.h +++ b/cpp/src/qpid/client/Message.h @@ -30,26 +30,48 @@ namespace qpid { namespace client { /** - * A representation of messages sent or received through the - * client api. + * A message sent to or received from the broker. * * \ingroup clientapi */ class Message : public framing::TransferContent { public: + /** Create a Message. + *@param data Data for the message body. + *@param routingKey Passed to the exchange that routes the message. + *@param exchange Name of the exchange that should route the message. + */ Message(const std::string& data=std::string(), const std::string& routingKey=std::string(), const std::string& exchange=std::string()); + + /** The destination of messages sent to the broker is the exchange + * name. The destination of messages received from the broker is + * the delivery tag identifyig the local subscription (often this + * is the name of the subscribed queue.) + */ std::string getDestination() const; + + /** Check the redelivered flag. */ bool isRedelivered() const; + /** Set the redelivered flag. */ void setRedelivered(bool redelivered); + + /** Get a modifyable reference to the message headers. */ framing::FieldTable& getHeaders(); + + /** Get a non-modifyable reference to the message headers. */ + const framing::FieldTable& getHeaders() const; + + ///@internal const framing::MessageTransferBody& getMethod() const; + ///@internal const framing::SequenceNumber& getId() const; /**@internal for incoming messages */ Message(const framing::FrameSet& frameset); + private: //method and id are only set for received messages: framing::MessageTransferBody method; diff --git a/cpp/src/qpid/client/MessageListener.h b/cpp/src/qpid/client/MessageListener.h index 86e5dd63dc..76e1d17445 100644 --- a/cpp/src/qpid/client/MessageListener.h +++ b/cpp/src/qpid/client/MessageListener.h @@ -29,16 +29,20 @@ namespace qpid { namespace client { /** - * An interface through which asynchronously delivered messages - * can be received by an application. - * - * @see Channel::consume() + * Implement a subclass of MessageListener and subscribe it using + * the SubscriptionManager to receive messages. + * + * Another way to receive messages is by using a LocalQueue. * * \ingroup clientapi */ class MessageListener{ public: virtual ~MessageListener(); + + /** Called for each message arriving from the broker. Override + * in your own subclass to process messages. + */ virtual void received(Message& msg) = 0; }; diff --git a/cpp/src/qpid/client/Queue.cpp b/cpp/src/qpid/client/Queue.cpp deleted file mode 100644 index 1752a48a3a..0000000000 --- a/cpp/src/qpid/client/Queue.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include "Queue.h" - -qpid::client::Queue::Queue() : name(""), autodelete(true), exclusive(true), durable(false){} - -qpid::client::Queue::Queue(std::string _name) : name(_name), autodelete(false), exclusive(false), durable(false){} - -qpid::client::Queue::Queue(std::string _name, bool temp) : name(_name), autodelete(temp), exclusive(temp), durable(false){} - -qpid::client::Queue::Queue(std::string _name, bool _autodelete, bool _exclusive, bool _durable) - : name(_name), autodelete(_autodelete), exclusive(_exclusive), durable(_durable){} - -const std::string& qpid::client::Queue::getName() const{ - return name; -} - -void qpid::client::Queue::setName(const std::string& _name){ - name = _name; -} - -bool qpid::client::Queue::isAutoDelete() const{ - return autodelete; -} - -bool qpid::client::Queue::isExclusive() const{ - return exclusive; -} - -bool qpid::client::Queue::isDurable() const{ - return durable; -} - -void qpid::client::Queue::setDurable(bool _durable){ - durable = _durable; -} - - - - diff --git a/cpp/src/qpid/client/Queue.h b/cpp/src/qpid/client/Queue.h deleted file mode 100644 index baaa890464..0000000000 --- a/cpp/src/qpid/client/Queue.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef _client_Queue_h -#define _client_Queue_h - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -#include <string> - -namespace qpid { -namespace client { - - /** - * DEPRECATED - * - * A 'handle' used to represent an AMQP queue in the Channel - * methods. Creating an instance of this class does not cause the - * queue to be created on the broker. Rather, an instance of this - * class should be passed to Channel::declareQueue() to ensure - * that the queue exists or is created. - * - * Queues hold messages and allow clients to consume - * (see Channel::consume()) or get (see Channel::get()) those messages. A - * queue receives messages by being bound to one or more Exchange. - * Messages published to that exchange may then be routed to the - * queue based on the details of the binding and the type of the - * exchange (see Channel::bind()). - * - * Queues are identified by a name. They can be exclusive (in which - * case they can only be used in the context of the connection - * over which they were declared, and are deleted when that - * connection closes), or they can be shared. Shared queues can be - * automatically deleted when they have no consumers. - * - * The term 'temporary queue' refers to an exclusive - * queue. - */ - class Queue{ - std::string name; - const bool autodelete; - const bool exclusive; - bool durable; - - public: - - /** - * Creates an unnamed, non-durable, temporary queue. A name - * will be assigned to this queue instance by a call to - * Channel::declareQueue(). - */ - Queue(); - /** - * Creates a shared, non-durable queue with a given name, - * that will not be automatically deleted. - * - * @param name the name of the queue. - */ - Queue(std::string name); - /** - * Creates a non-durable queue with a given name. - * - * @param name the name of the queue - * - * @param temp if true the queue will be a temporary queue, if - * false it will be shared and not automatically deleted. - */ - Queue(std::string name, bool temp); - /** - * This constructor allows the AutoDelete, Exclusive and - * Durable properties to be explictly set. Note however that if - * Exclusive is true, AutoDelete has no meaning as Exclusive - * queues are always destroyed when the connection that - * created them is closed. - */ - Queue(std::string name, bool autodelete, bool exclusive, bool durable); - const std::string& getName() const; - void setName(const std::string&); - bool isAutoDelete() const; - bool isExclusive() const; - bool isDurable() const; - void setDurable(bool durable); - }; - -} -} - -#endif /*!_client_Queue_h*/ diff --git a/cpp/src/qpid/client/Results.h b/cpp/src/qpid/client/Results.h index c325dcf1c5..667f35089c 100644 --- a/cpp/src/qpid/client/Results.h +++ b/cpp/src/qpid/client/Results.h @@ -31,6 +31,7 @@ namespace client { class FutureResult; +///@internal class Results { public: diff --git a/cpp/src/qpid/client/SessionBase_0_10.h b/cpp/src/qpid/client/SessionBase_0_10.h index 3b54b733c8..8634164dd1 100644 --- a/cpp/src/qpid/client/SessionBase_0_10.h +++ b/cpp/src/qpid/client/SessionBase_0_10.h @@ -48,6 +48,7 @@ using framing::SequenceNumberSet; using qpid::SessionId; using framing::Xid; +/** Unit of message credit: messages or bytes */ enum CreditUnit { MESSAGE_CREDIT=0, BYTE_CREDIT=1, UNLIMITED_CREDIT=0xFFFFFFFF }; /** @@ -61,6 +62,7 @@ class SessionBase_0_10 { typedef framing::TransferContent DefaultContent; + ///@internal SessionBase_0_10(); ~SessionBase_0_10(); diff --git a/cpp/src/qpid/client/SessionImpl.h b/cpp/src/qpid/client/SessionImpl.h index 3e46dc6b3a..55031a94ae 100644 --- a/cpp/src/qpid/client/SessionImpl.h +++ b/cpp/src/qpid/client/SessionImpl.h @@ -53,6 +53,7 @@ namespace client { class Future; class ConnectionImpl; +///@internal class SessionImpl : public framing::FrameHandler::InOutHandler, public Execution, private framing::AMQP_ClientOperations::SessionHandler, diff --git a/cpp/src/qpid/client/StateManager.h b/cpp/src/qpid/client/StateManager.h index 2f8ecb772c..b01664a0c1 100644 --- a/cpp/src/qpid/client/StateManager.h +++ b/cpp/src/qpid/client/StateManager.h @@ -27,6 +27,7 @@ namespace qpid { namespace client { +///@internal class StateManager { int state; diff --git a/cpp/src/qpid/client/SubscriptionManager.h b/cpp/src/qpid/client/SubscriptionManager.h index 1a00e1beeb..930175564e 100644 --- a/cpp/src/qpid/client/SubscriptionManager.h +++ b/cpp/src/qpid/client/SubscriptionManager.h @@ -36,7 +36,10 @@ namespace qpid { namespace client { /** - * Utility to assist with creating subscriptions. + * A class to help create and manage subscriptions. + * + * Set up your subscriptions, then call run() to have messages + * delivered. * * \ingroup clientapi */ @@ -58,10 +61,14 @@ class SubscriptionManager : public sys::Runnable bool autoStop; public: + /** Create a new SubscriptionManager associated with a session */ SubscriptionManager(const Session& session); /** * Subscribe a MessagesListener to receive messages from queue. + * + * Provide your own subclass of MessagesListener to process + * incoming messages. It will be called for each message received. * *@param listener Listener object to receive messages. *@param queue Name of the queue to subscribe to. @@ -69,12 +76,14 @@ class SubscriptionManager : public sys::Runnable * If not specified, the queue name is used. */ void subscribe(MessageListener& listener, - const std::string& queue, - const std::string& tag=std::string()); + const std::string& queue, + const std::string& tag=std::string()); /** * Subscribe a LocalQueue to receive messages from queue. * + * Incoming messages are stored in the queue for you to retrieve. + * *@param queue Name of the queue to subscribe to. *@param tag Unique destination tag for the listener. * If not specified, the queue name is used. diff --git a/cpp/src/qpid/client/TypedResult.h b/cpp/src/qpid/client/TypedResult.h index 79df9d0e69..5306997d74 100644 --- a/cpp/src/qpid/client/TypedResult.h +++ b/cpp/src/qpid/client/TypedResult.h @@ -30,7 +30,7 @@ namespace client { /** * Returned by asynchronous commands that return a result. * You can use get() to wait for completion and get the result value. - * \clientapi + * \ingroup clientapi */ template <class T> class TypedResult : public Completion { @@ -38,9 +38,17 @@ template <class T> class TypedResult : public Completion bool decoded; public: + ///@internal TypedResult(Future f, shared_ptr<SessionImpl> s) : Completion(f, s), decoded(false) {} - /** Wait for command to complete and return the result */ + /** + * Wait for the asynchronous command that returned this TypedResult to complete + * and return its result. + * + *@return The result returned by the command. + *@exception If the command returns an error, get() throws an exception. + * + */ T& get() { if (!decoded) { diff --git a/cpp/src/qpid/doxygen_mainpage.h b/cpp/src/qpid/doxygen_mainpage.h index b354238cd0..1502ef536e 100644 --- a/cpp/src/qpid/doxygen_mainpage.h +++ b/cpp/src/qpid/doxygen_mainpage.h @@ -1,45 +1,28 @@ // This header file is just for doxygen documentation purposes. -/*!\mainpage Qpid C++ Developer Kit. +/** \mainpage Qpid C++ Developer Kit. * - *\section intro_sec Introduction - * - * The <a href=http://incubator.apache.org/qpid/index.html>Qpid project</a> provides implementations of the <a href="http://amqp.org/">AMQP messaging specification</a> in several programming language. - * - * Qpidc provides APIs and libraries to implement AMQP - * clients in C++. Qpidc clients can interact with any compliant AMQP - * message broker. The Qpid project also provides an AMQP broker - * daemon called qpidd that you can use with your qpidc clients. - * - *\section install_sec Installation - * - * If you are installing from the source distribution - <pre> - > ./configure && make - > make install </pre> - * This will build and install the client development kit and the broker - * in standard places. Use - * <code>./configure --help</code> for more options. - * - * You can also install from RPMs with the <code>rpm -i</code> command. - * You will need - * - <code>qpidc</code> for core libraries. - * - <code>qpidc-devel</code> for header files and developer documentation. - * - <code>qpidd</code> for the broker daemon. - * - *\section getstart_sec Getting Started + * The <a href=http://incubator.apache.org/qpid>Qpid project</a> provides implementations of the <a href="http://amqp.org/">AMQP messaging specification</a> in several programming language. * - * If you have installed in the standard places you should use - * these compile flags: - * - *<code> -I/usr/include/qpidc -I/usr/include/qpidc/framing -I/usr/include/qpidc/sys</code> - * - * and these link flags: - * - *<code> -lqpidcommon -lqpidclient</code> + * Qpidc provides APIs and libraries to implement AMQP clients in + * C++. Qpidc clients can interact with any compliant AMQP message + * broker. The Qpid project also provides an AMQP broker daemon called + * qpidd that you can use with your qpidc clients. * - * If you have installed somewhere else you should modify the flags - * appropriately. + * See the \ref clientapi "client API reference" to get started. * - * See the \ref clientapi "client API module" for more on the client API. + */ + + +/** + * \defgroup clientapi Application API for an AMQP client. + * + * A typical client takes the following steps: + * - Connect to the broker using qpid::client::Connection::open() + * - Create a qpid::client::Session object. + * + * Once a session is created the client can work with the broker: + * - Create and bind queues using the qpid::client::Session commands. + * - Send messages using qpid::client::Session::messageTransfer. + * - Subscribe to queues using qpid::client::SubscriptionManager */ diff --git a/cpp/src/qpid/framing/TransferContent.h b/cpp/src/qpid/framing/TransferContent.h index f9f69da25e..7630421bd4 100644 --- a/cpp/src/qpid/framing/TransferContent.h +++ b/cpp/src/qpid/framing/TransferContent.h @@ -30,6 +30,7 @@ namespace qpid { namespace framing { +/** Message content */ class TransferContent : public MethodContent { AMQHeaderBody header; @@ -39,19 +40,24 @@ public: const std::string& routingKey = std::string(), const std::string& exchange = std::string()); + ///@internal AMQHeaderBody getHeader() const; - void setData(const std::string&); - void appendData(const std::string&); - MessageProperties& getMessageProperties(); - DeliveryProperties& getDeliveryProperties(); + void setData(const std::string&); const std::string& getData() const; std::string& getData(); - const MessageProperties& getMessageProperties() const; - const DeliveryProperties& getDeliveryProperties() const; + + void appendData(const std::string&); + bool hasMessageProperties() const; + MessageProperties& getMessageProperties(); + const MessageProperties& getMessageProperties() const; + bool hasDeliveryProperties() const; + DeliveryProperties& getDeliveryProperties(); + const DeliveryProperties& getDeliveryProperties() const; + ///@internal void populate(const FrameSet& frameset); }; diff --git a/cpp/src/tests/FramingTest.cpp b/cpp/src/tests/FramingTest.cpp index 21918f2bdd..f82507c0a7 100644 --- a/cpp/src/tests/FramingTest.cpp +++ b/cpp/src/tests/FramingTest.cpp @@ -18,8 +18,6 @@ * under the License. * */ -#include "qpid/client/Exchange.h" -#include "qpid/client/Queue.h" #include "qpid/client/Connection.h" #include "qpid/client/Connector.h" #include "qpid/framing/AMQP_HighestVersion.h" |