#include <Channel.h>
Public Member Functions | |
Channel (bool transactional=false, u_int16_t prefetch=0) | |
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=framing::FieldTable(), 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 that was opened if there has been no previous commit). | |
void | rollback () |
For a transactional channel, this will rollback any publications or acknowledgements. | |
void | setPrefetch (uint32_t prefetch) |
Change the prefetch in use. | |
uint32_t | getPrefetch () |
void | start () |
Start message dispatching on a new thread. | |
void | close () |
Close the channel. | |
bool | isTransactional () |
True if the channel is transactional. | |
bool | isOpen () const |
True if the channel is open. | |
framing::ProtocolVersion | getVersion () const |
Return the protocol version. | |
void | consume (Queue &queue, const std::string &tag, MessageListener *listener, AckMode ackMode=NO_ACK, bool noLocal=false, bool synch=true, 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 (Message &msg, const Exchange &exchange, const std::string &routingKey, bool mandatory=false, bool immediate=false) |
Publishes (i.e. | |
void | run () |
Deliver incoming messages to the appropriate MessageListener. |
Represents an AMQP channel, i.e. loosely a session of work. It is through a channel that most of the AMQP 'methods' are exposed.
qpid::client::Channel::Channel | ( | bool | transactional = false , |
|
u_int16_t | prefetch = 0 | |||
) |
Creates a channel object.
transactional | if true, the publishing and acknowledgement of messages will be transactional and can be committed or aborted in atomic units ( |
prefetch | specifies the number of unacknowledged messages the channel is willing to have sent to it asynchronously. |
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.
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::deleteExchange | ( | Exchange & | exchange, | |
bool | synch = true | |||
) |
Deletes an exchange.
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::declareQueue | ( | Queue & | queue, | |
bool | synch = true | |||
) |
void qpid::client::Channel::deleteQueue | ( | Queue & | queue, | |
bool | ifunused = false , |
|||
bool | ifempty = false , |
|||
bool | synch = true | |||
) |
void qpid::client::Channel::bind | ( | const Exchange & | exchange, | |
const Queue & | queue, | |||
const std::string & | key, | |||
const framing::FieldTable & | args = framing::FieldTable() , |
|||
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.
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::commit | ( | ) |
For a transactional channel this will commit all publications and acknowledgements since the last commit (or the channel that 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.
A channel is specified as transactional or not when the channel object is created (
void qpid::client::Channel::rollback | ( | ) |
For a transactional channel, this will rollback any publications or acknowledgements.
It will be as if the published messages were never sent and the acknowledged messages were never consumed.
void qpid::client::Channel::close | ( | ) |
Close the channel.
Closing a channel that is not open has no effect.
bool qpid::client::Channel::isTransactional | ( | ) | [inline] |
True if the channel is transactional.
bool qpid::client::Channel::isOpen | ( | ) | const |
True if the channel is open.
framing::ProtocolVersion qpid::client::Channel::getVersion | ( | ) | const [inline] |
Return the protocol version.
void qpid::client::Channel::consume | ( | Queue & | queue, | |
const std::string & | tag, | |||
MessageListener * | listener, | |||
AckMode | ackMode = NO_ACK , |
|||
bool | noLocal = false , |
|||
bool | synch = true , |
|||
framing::FieldTable * | fields = 0 | |||
) |
Creates a 'consumer' for a queue.
Messages in (or arriving at) that queue will be delivered to consumers asynchronously.
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. |
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::cancel | ( | const std::string & | tag, | |
bool | synch = true | |||
) |
Cancels a subscription previously set up through a call to consume().
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. |
Synchronous pull of a message from a queue.
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 ( |
void qpid::client::Channel::publish | ( | Message & | msg, | |
const Exchange & | exchange, | |||
const std::string & | routingKey, | |||
bool | mandatory = false , |
|||
bool | immediate = false | |||
) |
Publishes (i.e.
sends a message to the broker).
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()). |