Fixed documentation, removed references to the ChannelHandler - an object that is no longer supported by AMQP-CPP
This commit is contained in:
parent
b207ad7d17
commit
f23dc72a4f
14
README.md
14
README.md
|
|
@ -444,16 +444,16 @@ in almost any form:
|
|||
*
|
||||
* The following flags can be used
|
||||
*
|
||||
* - mandatory if set, an unroutable message will be reported to the
|
||||
* channel handler with the onReturned method
|
||||
* - mandatory if set, an unroutable message will be sent back to
|
||||
* the client (currently not supported)
|
||||
*
|
||||
* - immediate if set, a message that could not immediately be consumed
|
||||
* is returned to the onReturned method
|
||||
* is returned to the client (currently not supported)
|
||||
*
|
||||
* If either of the two flags is set, and the message could not immediately
|
||||
* be published, the message is returned by the server to the client. If you
|
||||
* want to catch such returned messages, you need to implement the
|
||||
* ChannelHandler::onReturned() method.
|
||||
* be published, the message is returned by the server to the client. However,
|
||||
* at this moment in time, the AMQP-CPP library does not support catching
|
||||
* such returned messages.
|
||||
*
|
||||
* @param exchange the exchange to publish to
|
||||
* @param routingkey the routing key
|
||||
|
|
@ -543,7 +543,7 @@ The full documentation from the C++ Channel.h headerfile looks like this:
|
|||
* - exclusive request exclusive access, only this consumer can
|
||||
* access the queue
|
||||
*
|
||||
* The method ChannelHandler::onConsumerStarted() will be called when the
|
||||
* The callback registered with DeferredConsumer::onSuccess() will be called when the
|
||||
* consumer has started.
|
||||
*
|
||||
* @param queue the queue from which you want to consume
|
||||
|
|
|
|||
|
|
@ -371,8 +371,8 @@ public:
|
|||
* Publish a message to an exchange
|
||||
*
|
||||
* If the mandatory or immediate flag is set, and the message could not immediately
|
||||
* be published, the message will be returned to the client, and will eventually
|
||||
* end up in your onReturned() handler method.
|
||||
* be published, the message will be returned to the client. However, the AMQP-CPP
|
||||
* library does not yet report such returned messages.
|
||||
*
|
||||
* @param exchange the exchange to publish to
|
||||
* @param routingkey the routing key
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* message, plus some additional information.
|
||||
*
|
||||
* Message objects can not be constructed by end users, they are only constructed
|
||||
* by the AMQP library, and passed to the ChannelHandler::onDelivered() method
|
||||
* by the AMQP library, and passed to user callbacks.
|
||||
*
|
||||
* @copyright 2014 Copernica BV
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -147,6 +147,16 @@ public:
|
|||
return _properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* The capabilities of the connection
|
||||
* @return Table
|
||||
*/
|
||||
const Table& capabilities() const
|
||||
{
|
||||
// retrieve the capabilities
|
||||
return _properties.get("capabilities");
|
||||
}
|
||||
|
||||
/**
|
||||
* Available security mechanisms
|
||||
* @return string
|
||||
|
|
@ -173,6 +183,12 @@ public:
|
|||
*/
|
||||
virtual bool process(ConnectionImpl *connection) override
|
||||
{
|
||||
// the capabilities
|
||||
Table capabilities;
|
||||
|
||||
// we want a special treatment for authentication failures
|
||||
capabilities["authentication_failure_close"] = true;
|
||||
|
||||
// the peer properties
|
||||
Table properties;
|
||||
|
||||
|
|
@ -182,6 +198,7 @@ public:
|
|||
properties["platform"] = "Unknown";
|
||||
properties["copyright"] = "Copyright 2014 Copernica BV";
|
||||
properties["information"] = "http://www.copernica.com";
|
||||
properties["capabilities"] = capabilities;
|
||||
|
||||
// move connection to handshake mode
|
||||
connection->setProtocolOk();
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ using namespace Copernica;
|
|||
* Constructor
|
||||
*/
|
||||
MyConnection::MyConnection(const std::string &ip) :
|
||||
_socket(Event::MainLoop::instance(), this),
|
||||
_connection(nullptr),
|
||||
_channel(nullptr)
|
||||
_socket(Event::MainLoop::instance(), this)
|
||||
{
|
||||
// start connecting
|
||||
if (_socket.connect(Network::Ipv4Address(ip), 5672)) return;
|
||||
|
|
@ -43,11 +41,6 @@ MyConnection::MyConnection(const std::string &ip) :
|
|||
*/
|
||||
MyConnection::~MyConnection()
|
||||
{
|
||||
// do we still have a channel?
|
||||
if (_channel) delete _channel;
|
||||
|
||||
// do we still have a connection?
|
||||
if (_connection) delete _connection;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,8 +76,8 @@ void MyConnection::onConnected(Network::TcpSocket *socket)
|
|||
if (_connection) return;
|
||||
|
||||
// create amqp connection, and a new channel
|
||||
_connection = new AMQP::Connection(this, AMQP::Login("guest", "guest"), "/");
|
||||
_channel = new AMQP::Channel(_connection);
|
||||
_connection = std::make_shared<AMQP::Connection>(this, AMQP::Login("guest1", "guest2"), "/");
|
||||
_channel = std::make_shared<AMQP::Channel>(_connection.get());
|
||||
|
||||
// install a handler when channel is in error
|
||||
_channel->onError([](const char *message) {
|
||||
|
|
@ -130,10 +123,6 @@ void MyConnection::onClosed(Network::TcpSocket *socket)
|
|||
// show
|
||||
std::cout << "myconnection closed" << std::endl;
|
||||
|
||||
// close the channel and connection
|
||||
if (_channel) delete _channel;
|
||||
if (_connection) delete _connection;
|
||||
|
||||
// set to null
|
||||
_channel = nullptr;
|
||||
_connection = nullptr;
|
||||
|
|
@ -148,10 +137,6 @@ void MyConnection::onLost(Network::TcpSocket *socket)
|
|||
// report error
|
||||
std::cout << "connection lost" << std::endl;
|
||||
|
||||
// close the channel and connection
|
||||
if (_channel) delete _channel;
|
||||
if (_connection) delete _connection;
|
||||
|
||||
// set to null
|
||||
_channel = nullptr;
|
||||
_connection = nullptr;
|
||||
|
|
@ -229,6 +214,6 @@ void MyConnection::onConnected(AMQP::Connection *connection)
|
|||
std::cout << "AMQP login success" << std::endl;
|
||||
|
||||
// create channel if it does not yet exist
|
||||
if (!_channel) _channel = new AMQP::Channel(connection);
|
||||
if (!_channel) _channel = std::make_shared<AMQP::Channel>(connection);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ private:
|
|||
* The AMQP connection
|
||||
* @var Connection
|
||||
*/
|
||||
AMQP::Connection *_connection;
|
||||
std::shared_ptr<AMQP::Connection> _connection;
|
||||
|
||||
/**
|
||||
* The AMQP channel
|
||||
* @var Channel
|
||||
*/
|
||||
AMQP::Channel *_channel;
|
||||
std::shared_ptr<AMQP::Channel> _channel;
|
||||
|
||||
/**
|
||||
* Method that is called when the connection failed
|
||||
|
|
|
|||
Loading…
Reference in New Issue