commit b176a33fc87cffe2d7b491640f0eceb6cf8b8e85 Author: linguini Date: Sun Jul 12 01:38:38 2026 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..78cb365 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libs/rmqcpp"] + path = libs/rmqcpp + url = https://github.com/bloomberg/rmqcpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d1e4f63 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.20) + +project(cpp_worker_dubla3) + +set(CMAKE_CXX_STANDARD 20) + +add_executable(cpp_worker_dubla3 + main.cpp + src/rmq/ConnectionHandler.cpp +) + +target_include_directories(cpp_worker_dubla3 PRIVATE + /usr/include +) + +target_link_directories(cpp_worker_dubla3 PRIVATE + /usr/lib +) + +target_link_libraries(cpp_worker_dubla3 PRIVATE + amqpcpp + pthread + dl + uv + ssl +) \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..c0fe30c --- /dev/null +++ b/main.cpp @@ -0,0 +1,32 @@ +#include "src/rmq/ConnectionHandler.hpp" +#include +#include +#include + +int main() +{ + // access to the event loop + auto *loop = uv_default_loop(); + + // handler for libev + ConnectionHandler handler(loop); + + // make a connection + AMQP::TcpConnection connection(&handler, AMQP::Address("amqp://proxmox:proxmox@mq.pseudot.org:5671")); + + // we need a channel too + AMQP::TcpChannel channel(&connection); + + // create a temporary queue + channel.declareQueue(AMQP::exclusive).onSuccess([&connection](const std::string &name, uint32_t messagecount, uint32_t consumercount) { + + // report the name of the temporary queue + std::cout << "declared queue " << name << std::endl; + }); + + // run the loop + uv_run(loop, UV_RUN_DEFAULT); + + // done + return 0; +} diff --git a/src/rmq/ConnectionHandler.cpp b/src/rmq/ConnectionHandler.cpp new file mode 100644 index 0000000..21ec911 --- /dev/null +++ b/src/rmq/ConnectionHandler.cpp @@ -0,0 +1,24 @@ +#include "ConnectionHandler.hpp" +#include + + void ConnectionHandler::onConnected(AMQP::TcpConnection *connection) + { + std::cout << "TCP CONNECTED\n"; + } + + + void ConnectionHandler::onReady(AMQP::TcpConnection *connection) + { + std::cout << "AMQP READY\n"; + } + + + void ConnectionHandler::onError( + AMQP::TcpConnection *connection, + const char *message) + { + std::cout << "ERROR: " + << message + << '\n'; + } + diff --git a/src/rmq/ConnectionHandler.hpp b/src/rmq/ConnectionHandler.hpp new file mode 100644 index 0000000..0edafec --- /dev/null +++ b/src/rmq/ConnectionHandler.hpp @@ -0,0 +1,19 @@ +#pragma once +#include +#include +#include + +class ConnectionHandler : public AMQP::LibUvHandler { +public: + ConnectionHandler(uv_loop_t *loop) + : AMQP::LibUvHandler(loop) + {} + + void onConnected(AMQP::TcpConnection *connection) override; + + void onReady(AMQP::TcpConnection *connection) override; + + void onError(AMQP::TcpConnection *connection, const char *message) override; + + ~ConnectionHandler() override = default; +};