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
|
* The following flags can be used
|
||||||
*
|
*
|
||||||
* - mandatory if set, an unroutable message will be reported to the
|
* - mandatory if set, an unroutable message will be sent back to
|
||||||
* channel handler with the onReturned method
|
* the client (currently not supported)
|
||||||
*
|
*
|
||||||
* - immediate if set, a message that could not immediately be consumed
|
* - 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
|
* 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
|
* be published, the message is returned by the server to the client. However,
|
||||||
* want to catch such returned messages, you need to implement the
|
* at this moment in time, the AMQP-CPP library does not support catching
|
||||||
* ChannelHandler::onReturned() method.
|
* such returned messages.
|
||||||
*
|
*
|
||||||
* @param exchange the exchange to publish to
|
* @param exchange the exchange to publish to
|
||||||
* @param routingkey the routing key
|
* @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
|
* - exclusive request exclusive access, only this consumer can
|
||||||
* access the queue
|
* 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.
|
* consumer has started.
|
||||||
*
|
*
|
||||||
* @param queue the queue from which you want to consume
|
* @param queue the queue from which you want to consume
|
||||||
|
|
|
||||||
|
|
@ -371,8 +371,8 @@ public:
|
||||||
* Publish a message to an exchange
|
* Publish a message to an exchange
|
||||||
*
|
*
|
||||||
* If the mandatory or immediate flag is set, and the message could not immediately
|
* 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
|
* be published, the message will be returned to the client. However, the AMQP-CPP
|
||||||
* end up in your onReturned() handler method.
|
* library does not yet report such returned messages.
|
||||||
*
|
*
|
||||||
* @param exchange the exchange to publish to
|
* @param exchange the exchange to publish to
|
||||||
* @param routingkey the routing key
|
* @param routingkey the routing key
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* message, plus some additional information.
|
* message, plus some additional information.
|
||||||
*
|
*
|
||||||
* Message objects can not be constructed by end users, they are only constructed
|
* 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
|
* @copyright 2014 Copernica BV
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ private:
|
||||||
* @var Table
|
* @var Table
|
||||||
*/
|
*/
|
||||||
Table _properties;
|
Table _properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available security mechanisms
|
* Available security mechanisms
|
||||||
* @var LongString
|
* @var LongString
|
||||||
|
|
@ -147,6 +147,16 @@ public:
|
||||||
return _properties;
|
return _properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The capabilities of the connection
|
||||||
|
* @return Table
|
||||||
|
*/
|
||||||
|
const Table& capabilities() const
|
||||||
|
{
|
||||||
|
// retrieve the capabilities
|
||||||
|
return _properties.get("capabilities");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available security mechanisms
|
* Available security mechanisms
|
||||||
* @return string
|
* @return string
|
||||||
|
|
@ -173,6 +183,12 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool process(ConnectionImpl *connection) override
|
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
|
// the peer properties
|
||||||
Table properties;
|
Table properties;
|
||||||
|
|
||||||
|
|
@ -182,6 +198,7 @@ public:
|
||||||
properties["platform"] = "Unknown";
|
properties["platform"] = "Unknown";
|
||||||
properties["copyright"] = "Copyright 2014 Copernica BV";
|
properties["copyright"] = "Copyright 2014 Copernica BV";
|
||||||
properties["information"] = "http://www.copernica.com";
|
properties["information"] = "http://www.copernica.com";
|
||||||
|
properties["capabilities"] = capabilities;
|
||||||
|
|
||||||
// move connection to handshake mode
|
// move connection to handshake mode
|
||||||
connection->setProtocolOk();
|
connection->setProtocolOk();
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,7 @@ using namespace Copernica;
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
MyConnection::MyConnection(const std::string &ip) :
|
MyConnection::MyConnection(const std::string &ip) :
|
||||||
_socket(Event::MainLoop::instance(), this),
|
_socket(Event::MainLoop::instance(), this)
|
||||||
_connection(nullptr),
|
|
||||||
_channel(nullptr)
|
|
||||||
{
|
{
|
||||||
// start connecting
|
// start connecting
|
||||||
if (_socket.connect(Network::Ipv4Address(ip), 5672)) return;
|
if (_socket.connect(Network::Ipv4Address(ip), 5672)) return;
|
||||||
|
|
@ -43,11 +41,6 @@ MyConnection::MyConnection(const std::string &ip) :
|
||||||
*/
|
*/
|
||||||
MyConnection::~MyConnection()
|
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;
|
if (_connection) return;
|
||||||
|
|
||||||
// create amqp connection, and a new channel
|
// create amqp connection, and a new channel
|
||||||
_connection = new AMQP::Connection(this, AMQP::Login("guest", "guest"), "/");
|
_connection = std::make_shared<AMQP::Connection>(this, AMQP::Login("guest1", "guest2"), "/");
|
||||||
_channel = new AMQP::Channel(_connection);
|
_channel = std::make_shared<AMQP::Channel>(_connection.get());
|
||||||
|
|
||||||
// install a handler when channel is in error
|
// install a handler when channel is in error
|
||||||
_channel->onError([](const char *message) {
|
_channel->onError([](const char *message) {
|
||||||
|
|
@ -130,10 +123,6 @@ void MyConnection::onClosed(Network::TcpSocket *socket)
|
||||||
// show
|
// show
|
||||||
std::cout << "myconnection closed" << std::endl;
|
std::cout << "myconnection closed" << std::endl;
|
||||||
|
|
||||||
// close the channel and connection
|
|
||||||
if (_channel) delete _channel;
|
|
||||||
if (_connection) delete _connection;
|
|
||||||
|
|
||||||
// set to null
|
// set to null
|
||||||
_channel = nullptr;
|
_channel = nullptr;
|
||||||
_connection = nullptr;
|
_connection = nullptr;
|
||||||
|
|
@ -148,10 +137,6 @@ void MyConnection::onLost(Network::TcpSocket *socket)
|
||||||
// report error
|
// report error
|
||||||
std::cout << "connection lost" << std::endl;
|
std::cout << "connection lost" << std::endl;
|
||||||
|
|
||||||
// close the channel and connection
|
|
||||||
if (_channel) delete _channel;
|
|
||||||
if (_connection) delete _connection;
|
|
||||||
|
|
||||||
// set to null
|
// set to null
|
||||||
_channel = nullptr;
|
_channel = nullptr;
|
||||||
_connection = nullptr;
|
_connection = nullptr;
|
||||||
|
|
@ -229,6 +214,6 @@ void MyConnection::onConnected(AMQP::Connection *connection)
|
||||||
std::cout << "AMQP login success" << std::endl;
|
std::cout << "AMQP login success" << std::endl;
|
||||||
|
|
||||||
// create channel if it does not yet exist
|
// 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
|
* The AMQP connection
|
||||||
* @var Connection
|
* @var Connection
|
||||||
*/
|
*/
|
||||||
AMQP::Connection *_connection;
|
std::shared_ptr<AMQP::Connection> _connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AMQP channel
|
* The AMQP channel
|
||||||
* @var Channel
|
* @var Channel
|
||||||
*/
|
*/
|
||||||
AMQP::Channel *_channel;
|
std::shared_ptr<AMQP::Channel> _channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that is called when the connection failed
|
* Method that is called when the connection failed
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue