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(); 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: public:
RabbitMQConnection(const RabbitMQConfiguration & configuration_, Poco::Logger * log_); RabbitMQConnection(const RabbitMQConfiguration & configuration_, Poco::Logger * log_);
~RabbitMQConnection();
bool isConnected(); bool isConnected();
bool connect(); bool connect();

View File

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