2020-05-20 09:40:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-06-02 13:15:53 +00:00
|
|
|
#include <thread>
|
2020-05-20 09:40:49 +00:00
|
|
|
#include <memory>
|
2020-06-02 13:15:53 +00:00
|
|
|
#include <mutex>
|
2020-05-20 09:40:49 +00:00
|
|
|
#include <amqpcpp.h>
|
|
|
|
#include <amqpcpp/linux_tcp.h>
|
|
|
|
#include <common/types.h>
|
2020-06-24 21:14:49 +00:00
|
|
|
#include <amqpcpp/libuv.h>
|
2020-05-20 09:40:49 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-06-24 21:14:49 +00:00
|
|
|
class RabbitMQHandler : public AMQP::LibUvHandler
|
2020-05-20 09:40:49 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2020-06-24 21:14:49 +00:00
|
|
|
RabbitMQHandler(uv_loop_t * evbase_, Poco::Logger * log_);
|
2020-05-20 09:40:49 +00:00
|
|
|
void onError(AMQP::TcpConnection * connection, const char * message) override;
|
2020-06-29 15:41:17 +00:00
|
|
|
|
|
|
|
void stop() { stop_loop.store(true); }
|
|
|
|
void startBackgroundLoop();
|
2020-06-27 17:26:00 +00:00
|
|
|
void startLoop();
|
2020-05-20 09:40:49 +00:00
|
|
|
|
|
|
|
private:
|
2020-06-24 21:14:49 +00:00
|
|
|
uv_loop_t * loop;
|
2020-05-20 09:40:49 +00:00
|
|
|
Poco::Logger * log;
|
2020-05-29 16:04:44 +00:00
|
|
|
|
2020-06-29 15:41:17 +00:00
|
|
|
std::atomic<bool> stop_loop = false;
|
2020-06-27 17:26:00 +00:00
|
|
|
std::timed_mutex starting_loop;
|
2020-05-20 09:40:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|