rabbitmq c++ client not connecting to rabbitmq-server at 5672 port -
i have installed rabbitmq-server on linux machine. have installed amqp-cpp client library given on official website of rabbirmq.enter link description here
now want connect rabbitmq-server producer , want publish message in queue. have made connection handler , main file follow:
int main(int argc, char** argv) { const std::string exchange = "my-exchange"; const std::string routingkey = "my-routing-key"; const char* message = "hello world"; mytcphandler myhandler; // address of server cout<< "tcphandler object created.." <<endl; amqp::address address("amqp://guest:guest@localhost:5672"); //("amqp://guest:guest@localhost/vhost"); cout<< "address object created.." <<endl; // create amqp connection object amqp::tcpconnection connection(&myhandler, address); cout<< "connection object created.." <<endl; // , create channel amqp::tcpchannel channel(&connection); cout<< "channel object created.." <<endl; // use channel object call amqp method channel.declareexchange("my-exchange", amqp::fanout); channel.declarequeue("my-queue"); channel.bindqueue("my-exchange", "my-queue", "my-routing-key"); cout<< "before publish.." <<endl; // start transaction channel.starttransaction(); int pubval = channel.publish(exchange, routingkey, message);
i not able connect queue. may not implementing "monitor" method correctly in mytcphandler class: virtual void monitor(amqp::tcpconnection *connection, int fd, int flags) can help, please?
Comments
Post a Comment