Apache Qpid C++ API
Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation

qpid::client::Connection Class Reference

Represents a connection to an AMQP broker. More...

#include <qpid/client/Connection.h>

List of all members.

Public Member Functions

 Connection ()
 Creates a Connection object, but does not open the connection.
 ~Connection ()
 Destroys a Connection object but does not close the connection if it was open.
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 Url &url, const ConnectionSettings &settings)
 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< UrlgetInitialBrokers ()
 In a cluster, returns the initial set of known broker URLs at the time of connection.
void registerFailureCallback (boost::function< void()> fn)
const ConnectionSettingsgetNegotiatedSettings ()
 Return the set of client negotiated settings.

Protected Attributes

boost::shared_ptr< ConnectionImpl > impl

Detailed Description

Represents a connection to an AMQP broker.

All communication is initiated by establishing a connection, then creating one or more Session objects using the connection.

See also:
newSession()

Some methods use an AMQP 0-10 URL to specify connection parameters. This is defined in the AMQP 0-10 specification (http://jira.amqp.org/confluence/display/AMQP/AMQP+Specification).

amqp_url = "amqp:" prot_addr_list prot_addr_list = [prot_addr ","]* prot_addr prot_addr = tcp_prot_addr | tls_prot_addr

tcp_prot_addr = tcp_id tcp_addr tcp_id = "tcp:" | "" tcp_addr = [host [":" port] ] host = <as per http://www.ietf.org/rfc/rfc3986.txt> port = number]]>

Definition at line 63 of file Connection.h.


Constructor & Destructor Documentation

qpid::client::Connection::Connection (  ) 

Creates a Connection object, but does not open the connection.

See also:
open()
qpid::client::Connection::~Connection (  ) 

Destroys a Connection object but does not close the connection if it was open.

See also:
close()

Member Function Documentation

void qpid::client::Connection::close (  ) 

Close the connection.

Any further use of this connection (without reopening it) will not succeed.

std::vector<Url> qpid::client::Connection::getInitialBrokers (  ) 

In a cluster, returns the initial set of known broker URLs at the time of connection.

const ConnectionSettings& qpid::client::Connection::getNegotiatedSettings (  ) 

Return the set of client negotiated settings.

bool qpid::client::Connection::isOpen (  )  const
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.

Parameters:
name,: A name to identify the session.
See also:
qpid::SessionId If the name is empty (the default) then a unique name will be chosen using a Universally-unique identifier (UUID) algorithm.
void qpid::client::Connection::open ( const ConnectionSettings settings  ) 

Opens a connection to a broker.

Parameters:
the settings to use (host, port etc).
See also:
ConnectionSettings.
void qpid::client::Connection::open ( const Url url,
const ConnectionSettings settings 
)

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.

Parameters:
settings used for any settings not provided by the URL. Settings provided by the url (e.g. host, port) are ignored.
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.

Parameters:
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 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.

Parameters:
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::registerFailureCallback ( boost::function< void()>  fn  ) 
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.


Member Data Documentation

boost::shared_ptr<ConnectionImpl> qpid::client::Connection::impl [protected]

Definition at line 71 of file Connection.h.


The documentation for this class was generated from the following file:

Qpid C++ API Reference
Generated on Mon Jun 7 17:49:08 2010 for Qpid C++ Client API by doxygen 1.6.2-20100208