-
Notifications
You must be signed in to change notification settings - Fork 362
Open
Description
Describe the bug
library won't publish a message unless heartbeat is received for SSL connection
Expected behavior and actual behavior
should publish instantly
Sample code
#include <amqpcpp.h>
#include <amqpcpp/libboostasio.h>
#include <boost/asio.hpp>
#include <openssl/ssl.h>
// .. some helpers omitted
int main() {
OPENSSL_init_ssl(0, nullptr);
boost::asio::io_context io;
Handler handler(io);
AMQP::TcpConnection connection(&handler, AMQP::Address("amqps://" HOST_NAME "/" VHOST_NAME));
AMQP::TcpChannel channel(&connection);
channel.declareQueue(QUEUE_NAME);
auto relChannel = AMQP::Reliable(channel);
auto consChannel = AMQP::TcpChannel(&connection);
consChannel.consume(QUEUE_NAME, AMQP::noack).onReceived([&consChannel](const AMQP::Message& msg, uint64_t tag, bool) {
Log() << "--- consumed: " << msg.body();
});
ReocurringTimer t(io, [&relChannel]() {
static int i{};
auto msg = std::format("m{}", ++i);
Log() << "--- publishing: " << msg;
relChannel.publish("", QUEUE_NAME, msg).onAck([msg]() { Log() << "publish acked: " << msg; });
}, std::chrono::seconds(2));
io.run();
}output:
[11:06:37] --- publishing: m1
[11:06:39] --- publishing: m2
[11:06:40] ** heartbeat received
[11:06:40] publish acked: m1
[11:06:40] publish acked: m2
[11:06:40] --- consumed: m1
[11:06:40] --- consumed: m2
[11:06:41] --- publishing: m3
[11:06:43] --- publishing: m4
[11:06:45] --- publishing: m5
[11:06:47] --- publishing: m6
[11:06:49] --- publishing: m7
[11:06:50] ** heartbeat received
[11:06:50] --- consumed: m3
[11:06:50] publish acked: m3
[11:06:50] publish acked: m4
[11:06:50] publish acked: m5
[11:06:50] --- consumed: m4
[11:06:50] --- consumed: m5
[11:06:50] --- consumed: m6
[11:06:50] --- consumed: m7
[11:06:50] publish acked: m6
[11:06:50] publish acked: m7
[11:06:51] --- publishing: m8
[11:06:53] --- publishing: m9
...
CMakeLists.tst:
cmake_minimum_required(VERSION 3.20)
project(amqp_secure_demo LANGUAGES CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(OpenSSL 3.6.0 EXACT REQUIRED)
find_package(Boost 1.88.0 EXACT REQUIRED)
find_package(amqpcpp 4.3.27 EXACT REQUIRED)
add_executable(amqp_secure_demo main.cpp)
target_link_libraries(amqp_secure_demo
PRIVATE
amqpcpp
boost::boost
openssl::openssl
)
tested on RabbitMQ 3.13.7, Arch Linux 6.17.1, GCC 15.2.1
Metadata
Metadata
Assignees
Labels
No labels