#include <Connection.h>
Public Member Functions | |
Connection () | |
Creates a connection object, but does not open the connection. | |
void | open (const std::string &host, int port=5672, const std::string &uid="guest", const std::string &pwd="guest", const std::string &virtualhost="/", uint16_t maxFrameSize=65535) |
Opens a connection to a broker. | |
void | open (const Url &url, const std::string &uid="guest", const std::string &pwd="guest", const std::string &virtualhost="/", uint16_t maxFrameSize=65535) |
Opens a connection to a broker using a URL. | |
void | open (const ConnectionSettings &settings) |
Opens a connection to a broker. | |
void | close () |
Close the connection. | |
Session | newSession (const std::string &name=std::string(), uint32_t timeoutSeconds=0) |
Create a new session on this connection. | |
void | resume (Session &session) |
Resume a suspended session. | |
bool | isOpen () const |
std::vector< Url > | getKnownBrokers () |
void | registerFailureCallback (boost::function< void()> fn) |
Protected Attributes | |
boost::shared_ptr< ConnectionImpl > | impl |
All communication is initiated by establishing a connection, then creating one or more Session objecst using the connection.
Definition at line 44 of file Connection.h.
qpid::client::Connection::Connection | ( | ) |
void qpid::client::Connection::open | ( | const std::string & | host, | |
int | port = 5672 , |
|||
const std::string & | uid = "guest" , |
|||
const std::string & | pwd = "guest" , |
|||
const std::string & | virtualhost = "/" , |
|||
uint16_t | maxFrameSize = 65535 | |||
) |
Opens a connection to a broker.
host | the host on which the broker is running. | |
port | the port on the which the broker is listening. | |
uid | the userid to connect with. | |
pwd | the password to connect with (currently SASL PLAIN is the only authentication method supported so this is sent in clear text). | |
virtualhost | the AMQP virtual host to use (virtual hosts, where implemented(!), provide namespace partitioning within a single broker). |
void qpid::client::Connection::open | ( | const Url & | url, | |
const std::string & | uid = "guest" , |
|||
const std::string & | pwd = "guest" , |
|||
const std::string & | virtualhost = "/" , |
|||
uint16_t | maxFrameSize = 65535 | |||
) |
Opens a connection to a broker using a URL.
If the URL contains multiple addresses, try each in turn till connection is successful.
address of the broker to connect to.
uid | the userid to connect with. | |
pwd | the password to connect with (currently SASL PLAIN is the only authentication method supported so this is sent in clear text). | |
virtualhost | the AMQP virtual host to use (virtual hosts, where implemented(!), provide namespace partitioning within a single broker). |
void qpid::client::Connection::open | ( | const ConnectionSettings & | settings | ) |
Opens a connection to a broker.
the | settings to use (host, port etc) |
void qpid::client::Connection::close | ( | ) |
Close the connection.
Any further use of this connection (without reopening it) will not succeed.
Session qpid::client::Connection::newSession | ( | const std::string & | name = std::string() , |
|
uint32_t | timeoutSeconds = 0 | |||
) |
Create a new session on this connection.
Sessions allow multiple streams of work to be multiplexed over the same connection. The returned Session provides functions to send commands to the broker.
Session functions are synchronous. In other words, a Session function will send a command to the broker and does not return until it receives the broker's response confirming the command was executed.
AsyncSession provides asynchronous versions of the same functions. These functions send a command to the broker but do not wait for a response.
You can convert a Session s into an AsyncSession as follows:
#include <qpid/client/AsyncSession.h> AsyncSession as = async(s);
You can execute a single command asynchronously will a Session s like ths:
async(s).messageTransfer(...);
Using an AsyncSession is faster for sending large numbers of commands, since each command is sent as soon as possible without waiting for the previous command to be confirmed.
However with AsyncSession you cannot assume that a command has completed until you explicitly synchronize. The simplest way to do this is to call Session::sync() or AsyncSession::sync(). Both of these functions wait for the broker to confirm all commands issued so far on the session.
name,: | A name to identify the session. |
void qpid::client::Connection::resume | ( | Session & | session | ) |
Resume a suspended session.
A session may be resumed on a different connection to the one that created it.