Add logging, remove closing connection in destructor

This commit is contained in:
kssenii 2023-01-04 18:08:55 +01:00
parent 283388cfa6
commit 2e758f983f
3 changed files with 6 additions and 23 deletions

View File

@ -122,24 +122,4 @@ void RabbitMQConnection::disconnectImpl(bool immediately)
event_handler.iterateLoop();
}
RabbitMQConnection::~RabbitMQConnection()
{
std::lock_guard lock(mutex);
if (!connection)
return;
try
{
/// Try to always close the connection gracefully (run the loop to see the closing callbacks)
/// to make sure that the associated callbacks and pending events are removed
/// before handler and loop are destructed.
disconnectImpl();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
}

View File

@ -24,8 +24,6 @@ class RabbitMQConnection
public:
RabbitMQConnection(const RabbitMQConfiguration & configuration_, Poco::Logger * log_);
~RabbitMQConnection();
bool isConnected();
bool connect();

View File

@ -621,7 +621,6 @@ void StorageRabbitMQ::prepareChannelForConsumer(RabbitMQConsumerPtr consumer)
consumer->setupChannel();
}
void StorageRabbitMQ::unbindExchange()
{
/* This is needed because with RabbitMQ (without special adjustments) can't, for example, properly make mv if there was insert query
@ -812,6 +811,8 @@ void StorageRabbitMQ::shutdown()
{
shutdown_called = true;
LOG_TRACE(log, "Deactivating background tasks");
/// In case it has not yet been able to setup connection;
deactivateTask(connection_task, true, false);
@ -820,6 +821,8 @@ void StorageRabbitMQ::shutdown()
deactivateTask(streaming_task, true, false);
deactivateTask(looping_task, true, true);
LOG_TRACE(log, "Cleaning up RabbitMQ after table usage");
/// Just a paranoid try catch, it is not actually needed.
try
{
@ -842,6 +845,8 @@ void StorageRabbitMQ::shutdown()
{
tryLogCurrentException(log);
}
LOG_TRACE(log, "Shutdown finished");
}