RMQ publish is incosistent

23 views
Skip to first unread message

Mangesh Ghaisas

unread,
Feb 7, 2023, 12:05:31 PM2/7/23
to rabbitmq-users
Hi,
I'm using AMQPCPP for my project. and suing following code to publish message on amq.direct exchange.
##########################################################
#include <iostream> #include <sstream> #include <vector> #include <boost/asio/io_service.hpp> #include <boost/asio/strand.hpp> #include <boost/asio/deadline_timer.hpp> #include <thread> #include <amqpcpp.h> #include <amqpcpp/libboostasio.h> void publish_event_to_rabbitmq(AMQP::TcpChannel* channel,std::vector<std::string> routing_keys) { //value of routing_keys = {"TRIGGER","EVENTS"} for (auto key : routing_keys) { std :: cout << key << " routing key" <<std :: endl; channel->publish("",key, key); } } int main() { boost::asio::io_service service(4); AMQP::LibBoostAsioHandler handler(service); AMQP::TcpConnection connection(&handler, AMQP::Address("amqp://user:password@localhost/")); AMQP::TcpChannel channel(&connection); while(true) { publish_event_to_rabbitmq(&channel,{"TRIGGER","EVENTS}); sleep(10); } service.run(); }
###############################################################
some times code works sometime doesn't not getting what is problem please help

Reply all
Reply to author
Forward
0 new messages