panic icon indicating copy to clipboard operation
panic copied to clipboard

Refactor alerter to use 1 rabbitMQ connection per thread

Open Cherrett opened this issue 3 years ago • 1 comments

When tackling #136, it was noted that we are sharing rabbitMQ connections between threads. This is not correct and each thread should have its own connection.

Cherrett avatar Mar 24 '22 11:03 Cherrett

Comment left by @dillu24 on 136 MR:

Also as per pika docs, it is recommended that we use 1 connection per thread, where the connection is created inside that thread. I don't think we are doing that.

I think we should use separate initialisation functions for each thread, and we use the appropriate rabbit initialization function according to which thread we are in.

For example we should have a general initialise_rabbit function which initialises the queues and exchanges and then disconnects from rabbit in the mainthread. Then we should have an initialize_rabbit_heartbeat which initialises a rabbit connection for the ping thread and initialize_rabbit_sending_configs which initialises a connection for the sending_configs thread. When on the outside we terminate the threads we disconnect as normal. Due to this we must then have 2 variables, is_connected_rabbit_heartbeat and is_connected_rabbit_send_configs.

Cherrett avatar Mar 24 '22 11:03 Cherrett