implement tcp handler and pass reason to callback
This commit is contained in:
parent
4fb968f7a4
commit
89ba9138c0
|
|
@ -204,8 +204,9 @@ public:
|
|||
* disk space, another notification will not be sent.
|
||||
*
|
||||
* @param connection The connection that was blocked
|
||||
* @param reason Why was the connection blocked
|
||||
*/
|
||||
virtual void onBlocked(Connection *connection)
|
||||
virtual void onBlocked(Connection *connection, const char *reason)
|
||||
{
|
||||
// make sure compilers dont complain about unused parameters
|
||||
(void) connection;
|
||||
|
|
|
|||
|
|
@ -430,11 +430,12 @@ public:
|
|||
|
||||
/**
|
||||
* Report that the connection is blocked
|
||||
* @param reason
|
||||
*/
|
||||
void reportBlocked()
|
||||
void reportBlocked(const char *reason)
|
||||
{
|
||||
// inform the handler
|
||||
_handler->onBlocked(_parent);
|
||||
_handler->onBlocked(_parent, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -117,6 +117,27 @@ private:
|
|||
*/
|
||||
virtual void onClosed(Connection *connection) override;
|
||||
|
||||
/**
|
||||
* Method that is called when the AMQP connection was blocked.
|
||||
* @param connection The connection that was blocked
|
||||
* @param reason Why was the connection blocked
|
||||
*/
|
||||
virtual void onBlocked(Connection *connection, const char *reason) override
|
||||
{
|
||||
// pass to user space
|
||||
if (_handler) _handler->onBlocked(this, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the AMQP connection is no longer blocked.
|
||||
* @param connection The connection that is no longer blocked
|
||||
*/
|
||||
virtual void onUnblocked(Connection *connection)
|
||||
{
|
||||
// pass to user space
|
||||
if (_handler) _handler->onUnblocked(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the tcp connection has been established
|
||||
* @param state
|
||||
|
|
|
|||
|
|
@ -191,6 +191,39 @@ public:
|
|||
(void) connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the AMQP connection was blocked.
|
||||
*
|
||||
* This method is called, when the server connection gets blocked for the first
|
||||
* time due to the broker running low on a resource (memory or disk). For
|
||||
* example, when a RabbitMQ node detects that it is low on RAM, it sends a
|
||||
* notification to all connected publishing clients supporting this feature.
|
||||
* If before the connections are unblocked the node also starts running low on
|
||||
* disk space, another notification will not be sent.
|
||||
*
|
||||
* @param connection The connection that was blocked
|
||||
* @param reason Why was the connection blocked
|
||||
*/
|
||||
virtual void onBlocked(TcpConnection *connection, const char *reason)
|
||||
{
|
||||
// make sure compilers dont complain about unused parameters
|
||||
(void) connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the AMQP connection is no longer blocked.
|
||||
*
|
||||
* This method is called when all resource alarms have cleared and the
|
||||
* connection is fully unblocked.
|
||||
*
|
||||
* @param connection The connection that is no longer blocked
|
||||
*/
|
||||
virtual void onUnblocked(TcpConnection *connection)
|
||||
{
|
||||
// make sure compilers dont complain about unused parameters
|
||||
(void) connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the TCP connection is lost or closed. This
|
||||
* is always called if you have also received a call to onConnected().
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public:
|
|||
virtual bool process(ConnectionImpl *connection) override
|
||||
{
|
||||
// report that it is blocked
|
||||
connection->reportBlocked();
|
||||
connection->reportBlocked(this->reason().c_str());
|
||||
|
||||
// done
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue