qpid::client::Channel Class Reference
[Application API for an AMQP client]

Represents an AMQP channel, i.e. More...

#include <ClientChannel.h>

Inheritance diagram for qpid::client::Channel:

Inheritance graph
[legend]
Collaboration diagram for qpid::client::Channel:

Collaboration graph
[legend]
List of all members.

Public Types

 AMQP_08
 AMQP_09
enum  InteropMode { AMQP_08, AMQP_09 }

Public Member Functions

 Channel (bool transactional=false, u_int16_t prefetch=500, InteropMode=AMQP_08)
 Creates a channel object.
void declareExchange (Exchange &exchange, bool synch=true)
 Declares an exchange.
void deleteExchange (Exchange &exchange, bool synch=true)
 Deletes an exchange.
void declareQueue (Queue &queue, bool synch=true)
 Declares a Queue.
void deleteQueue (Queue &queue, bool ifunused=false, bool ifempty=false, bool synch=true)
 Deletes a Queue.
void bind (const Exchange &exchange, const Queue &queue, const std::string &key, const framing::FieldTable &args, bool synch=true)
 Binds a queue to an exchange.
void commit ()
 For a transactional channel this will commit all publications and acknowledgements since the last commit (or the channel was opened if there has been no previous commit).
void rollback ()
 For a transactional channel, this will rollback any publications or acknowledgements.
void setPrefetch (uint16_t prefetch)
 Change the prefetch in use.
uint16_t getPrefetch ()
void start ()
 Start message dispatching on a new thread.
void close (framing::ReplyCode=200, const std::string &="OK", framing::ClassId=0, framing::MethodId=0)
 Close the channel with optional error information.
bool isTransactional ()
 True if the channel is transactional.
bool isOpen () const
 True if the channel is open.
ConnectiongetConnection ()
 Get the connection associated with this channel.
framing::ProtocolVersion getVersion () const
 Return the protocol version.
void consume (Queue &queue, std::string &tag, MessageListener *listener, AckMode ackMode=NO_ACK, bool noLocal=false, bool synch=true, const framing::FieldTable *fields=0)
 Creates a 'consumer' for a queue.
void cancel (const std::string &tag, bool synch=true)
 Cancels a subscription previously set up through a call to consume().
bool get (Message &msg, const Queue &queue, AckMode ackMode=NO_ACK)
 Synchronous pull of a message from a queue.
void publish (const Message &msg, const Exchange &exchange, const std::string &routingKey, bool mandatory=false, bool immediate=false)
 Publishes (i.e.
void setReturnedMessageHandler (ReturnedMessageHandler *handler)
 Set a handler for this channel that will process any returned messages.
void run ()
 Deliver messages from the broker to the appropriate MessageListener.

Detailed Description

Represents an AMQP channel, i.e.

loosely a session of work. It is through a channel that most of the AMQP 'methods' are exposed.


Constructor & Destructor Documentation

qpid::client::Channel::Channel ( bool  transactional = false,
u_int16_t  prefetch = 500,
InteropMode  = AMQP_08 
)

Creates a channel object.

Parameters:
transactional if true, the publishing and acknowledgement of messages will be transactional and can be committed or aborted in atomic units (
See also:
commit(),

rollback())

Parameters:
prefetch specifies the number of unacknowledged messages the channel is willing to have sent to it asynchronously
messageImpl Alternate messaging implementation class to allow alternate protocol implementations of messaging operations. Takes ownership.


Member Function Documentation

void qpid::client::Channel::bind ( const Exchange exchange,
const Queue queue,
const std::string &  key,
const framing::FieldTable args,
bool  synch = true 
)

Binds a queue to an exchange.

The exact semantics of this (in particular how 'routing keys' and 'binding arguments' are used) depends on the type of the exchange.

Parameters:
exchange an Exchange object representing the exchange to bind to
queue a Queue object representing the queue to be bound
key the 'routing key' for the binding
args the 'binding arguments' for the binding
synch if true this call will block until a response is received from the broker

void qpid::client::Channel::cancel ( const std::string &  tag,
bool  synch = true 
)

Cancels a subscription previously set up through a call to consume().

Parameters:
tag the identifier used (or assigned) in the consume request that set up the subscription to be cancelled.
synch if true this call will block until a response is received from the broker

void qpid::client::Channel::close ( framing::ReplyCode  = 200,
const std::string &  = "OK",
framing::ClassId  = 0,
framing::MethodId  = 0 
)

Close the channel with optional error information.

Closing a channel that is not open has no effect.

void qpid::client::Channel::commit (  ) 

For a transactional channel this will commit all publications and acknowledgements since the last commit (or the channel was opened if there has been no previous commit).

This will cause published messages to become available to consumers and acknowledged messages to be consumed and removed from the queues they were dispatched from.

Transactionailty of a channel is specified when the channel object is created (

See also:
Channel()).

void qpid::client::Channel::consume ( Queue queue,
std::string &  tag,
MessageListener listener,
AckMode  ackMode = NO_ACK,
bool  noLocal = false,
bool  synch = true,
const framing::FieldTable fields = 0 
)

Creates a 'consumer' for a queue.

Messages in (or arriving at) that queue will be delivered to consumers asynchronously.

Parameters:
queue a Queue instance representing the queue to consume from
tag an identifier to associate with the consumer that can be used to cancel its subscription (if empty, this will be assigned by the broker)
listener a pointer to an instance of an implementation of the MessageListener interface. Messages received from this queue for this consumer will result in invocation of the received() method on the listener, with the message itself passed in.
ackMode the mode of acknowledgement that the broker should assume for this consumer.
See also:
AckMode
Parameters:
noLocal if true, this consumer will not be sent any message published by this connection
synch if true this call will block until a response is received from the broker

void qpid::client::Channel::declareExchange ( Exchange exchange,
bool  synch = true 
)

Declares an exchange.

In AMQP Exchanges are the destinations to which messages are published. They have Queues bound to them and route messages they receive to those queues. The routing rules depend on the type of the exchange.

Parameters:
exchange an Exchange object representing the exchange to declare
synch if true this call will block until a response is received from the broker

void qpid::client::Channel::declareQueue ( Queue queue,
bool  synch = true 
)

Declares a Queue.

Parameters:
queue a Queue object representing the queue to declare
synch if true this call will block until a response is received from the broker

void qpid::client::Channel::deleteExchange ( Exchange exchange,
bool  synch = true 
)

Deletes an exchange.

Parameters:
exchange an Exchange object representing the exchange to delete
synch if true this call will block until a response is received from the broker

void qpid::client::Channel::deleteQueue ( Queue queue,
bool  ifunused = false,
bool  ifempty = false,
bool  synch = true 
)

Deletes a Queue.

Parameters:
queue a Queue object representing the queue to delete
synch if true this call will block until a response is received from the broker

bool qpid::client::Channel::get ( Message msg,
const Queue queue,
AckMode  ackMode = NO_ACK 
)

Synchronous pull of a message from a queue.

Parameters:
msg a message object that will contain the message headers and content if the call completes.
queue the queue to consume from
ackMode the acknowledgement mode to use (
See also:
AckMode)
Returns:
true if a message was succcessfully dequeued from the queue, false if the queue was empty.

void qpid::client::Channel::publish ( const Message msg,
const Exchange exchange,
const std::string &  routingKey,
bool  mandatory = false,
bool  immediate = false 
)

Publishes (i.e.

sends a message to the broker).

Parameters:
msg the message to publish
exchange the exchange to publish the message to
routingKey the routing key to publish with
mandatory if true and the exchange to which this publish is directed has no matching bindings, the message will be returned (see setReturnedMessageHandler()).
immediate if true and there is no consumer to receive this message on publication, the message will be returned (see setReturnedMessageHandler()).

void qpid::client::Channel::rollback (  ) 

For a transactional channel, this will rollback any publications or acknowledgements.

It will be as if the ppblished messages were never sent and the acknowledged messages were never consumed.

void qpid::client::Channel::setReturnedMessageHandler ( ReturnedMessageHandler handler  ) 

Set a handler for this channel that will process any returned messages.

See also:
publish()


The documentation for this class was generated from the following file:
Generated on Tue Apr 17 14:22:17 2007 for Qpid by  doxygen 1.4.7