rabbitmq的编译
下载
https://github.com/alanxz/rabbitmq-c/releases/tag/v0.8.0
解压并修改文件夹名称
新建build文件夹
打开CMakeGui进行编译
通过VS2017打开工程
生成库
结果
boost的编译
下载
https://dl.bintray.com/boostorg/release/1.66.0/source/
解压到目录
打开VS环境命令行
到工作目录执行bootstrap.bat
编译
b2.exe --build-type=complete --build-dir=build toolset=msvc-14.1 address-model=32 stage --stagedir="./VS2017"
安装
b2.exe --build-type=complete --build-dir=build toolset=msvc-14.1 address-model=32 install
结果
编译SimpleAmqpClient
修改Channel.cpp
配置CMAKE
打开程序并生成解决方案
编写测试工程
代码
#include "ConnMgr.h"
#include "SimpleAmqpClient/SimpleAmqpClient.h"
ConnMgr::ConnMgr()
{
try
{
auto conn= AmqpClient::Channel::Create("172.16.2.27", 5672, "admin", "admin", "admin");
//auto conn = AmqpClient::Channel::Create("localhost");
if (!conn)
{
std::cout << "connection error..." << std::endl;
}
conn->DeclareExchange("logs", "fanout", false, true);
std::string queue = conn->DeclareQueue("");
conn->BindQueue(queue, "logs", "");
std::string buffer = conn->BasicConsume(queue, "", false, true, false);
while (true)
{
auto consume=conn->BasicConsumeMessage();
buffer = consume->Message()->Body();
std::cout << "receive data..."<< buffer << std::endl;
}
}
catch (std::exception e)
{
std::cout << "connection error..." << e.what() << std::endl;
}
}
ConnMgr::~ConnMgr()
{
}