implement tcp handler and pass reason to callback
This commit is contained in:
parent
4fb968f7a4
commit
89ba9138c0
|
|
@ -204,9 +204,10 @@ public:
|
||||||
* disk space, another notification will not be sent.
|
* disk space, another notification will not be sent.
|
||||||
*
|
*
|
||||||
* @param connection The connection that was blocked
|
* @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
|
// make sure compilers dont complain about unused parameters
|
||||||
(void) connection;
|
(void) connection;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -430,11 +430,12 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report that the connection is blocked
|
* Report that the connection is blocked
|
||||||
|
* @param reason
|
||||||
*/
|
*/
|
||||||
void reportBlocked()
|
void reportBlocked(const char *reason)
|
||||||
{
|
{
|
||||||
// inform the handler
|
// inform the handler
|
||||||
_handler->onBlocked(_parent);
|
_handler->onBlocked(_parent, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,28 @@ private:
|
||||||
* @param connection The connection that was closed and that is now unusable
|
* @param connection The connection that was closed and that is now unusable
|
||||||
*/
|
*/
|
||||||
virtual void onClosed(Connection *connection) override;
|
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
|
* Method that is called when the tcp connection has been established
|
||||||
* @param state
|
* @param state
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,40 @@ public:
|
||||||
// make sure compilers dont complain about unused parameters
|
// make sure compilers dont complain about unused parameters
|
||||||
(void) connection;
|
(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
|
* 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().
|
* is always called if you have also received a call to onConnected().
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public:
|
||||||
virtual bool process(ConnectionImpl *connection) override
|
virtual bool process(ConnectionImpl *connection) override
|
||||||
{
|
{
|
||||||
// report that it is blocked
|
// report that it is blocked
|
||||||
connection->reportBlocked();
|
connection->reportBlocked(this->reason().c_str());
|
||||||
|
|
||||||
// done
|
// done
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue