I use AMQP-CPP for running RabbitMQ TCP server and use libuv library for event loop. I have created a class RabbitMQ where I initialize all necessary AMQP-CPP stuff this way:
m_loop = uv_loop_new();
m_handler = std::make_unique<AMQP::LibUvHandler>(m_loop);
m_connection = std::make_shared<AMQP::TcpConnection>(m_handler.get(), AMQP::Address(m_uri));
Then I run libuv loop in new thread:
m_working_thread = std::thread([&]{
// some thread sync stuff (lock_guard etc)
uv_run(m_loop, UV_RUN_NOWAIT);
});
My class RabbitMQ creates an object Server where I pass shared_ptr to AMQP::TcpConnection to initialize AMQP::TcpChannel
m_channel(std::make_unique<AMQP::TcpChannel>(m_connection.get()))
The problem is TCP channel is not getting ready - my server has initialized and nothing happening, no errors in logs, neither onReady nor onError event handler is fired.
What can be the problem here?
I checked readiness of TCP channel using methods usable() and ready() in the class Server where I define event handlers for TCP channel. Channel is usable, but not ready. Moreover I tried UV_RUN_DEFAULT in place of UV_RUN_NOWAIT. This works but I need to poll for new events only once. So UV_RUN_NOWAIT is my case.