因为项目原因,需要使用到rabbitmq的c客户端库。首先,参见上一篇windows下openssl编译,如果已经使用cmake编译过了,则先delete cache(File-Delete Cache),否则原来的cmake缓存都在了,将仍然会出现原来的错误。

依次点击configire、generate,可以生成vs sln。如下:

最后使用VS即可生成rabbitmq.4.dll,如下:

测试自带的例子:

D:\RabbitMQ Server\rabbitmq_server-3.6.5\sbin>cd /d D:\rabbitmq-c-0.8.0-build\examples\Debug

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_listen localhost 5672 amq.direct test
Delivery 1, exchange amq.direct routingkey test
Content-type: text/plain
----
00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64 hello world
0000000B:
Delivery 2, exchange amq.direct routingkey test
Content-type: text/plain
----
00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64 hello world
0000000B:
Delivery 3, exchange amq.direct routingkey test
Content-type: text/plain
----
00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64 hello world
0000000B:
Delivery 4, exchange amq.direct routingkey test

新开一个窗口,执行如下:

D:\RabbitMQ Server\rabbitmq_server-3.6.5\sbin>cd /d D:\rabbitmq-c-0.8.0-build\examples\Debug

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

D:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_sendstring localhost 5672 amq.direct test "hello world"

需要注意的是,librabbitmq的channel不是线程安全的,因此需要应用自行保证线程安全性,如下所述:

Threading

You cannot share a socket, an amqp_connection_state_t, or a channel between threads using librabbitmq. The librabbitmqlibrary is built with event-driven, single-threaded applications in mind, and does not yet cater to any of the requirements of pthreaded applications.

Your applications instead should open an AMQP connection (and an associated socket, of course) per thread. If your program needs to access an AMQP connection or any of its channels from more than one thread, it is entirely responsible for designing and implementing an appropriate locking scheme. It will generally be much simpler to have a connection exclusive to each thread that needs AMQP service.

官方主页https://github.com/alanxz/rabbitmq-c

doc api http://alanxz.github.io/rabbitmq-c/docs/0.8.0/classes.html

剩下的就是慢慢啃主要的api了。

最新文章

  1. c++单例模式为什么不在析构函数中释放静态的单例对象(转)
  2. UnitOfWork以及其在ABP中的应用
  3. 如何用Endnote导入你要用的格式
  4. QTP11.00安装+破解详细教程
  5. 图像处理控件ImageGear for .NET教程如何为应用程序 添加DICOM功能(2)
  6. Android-简单的sdcard文件浏览
  7. VMware 进入bios
  8. [转]fedora启动telnet服务
  9. Ajax:Cross-Origin Resource Sharing(转)
  10. .net 链接oracle
  11. 数据库sqlite的使用
  12. 微信公众平台应用开发框架sophia设计不足(1)
  13. 设计模式六大原则-OCP
  14. linux视频学习4(crontab和进程)
  15. MDK下调试时提示AXF文件无法导入的解决方法(转)
  16. The Lisp Curse /Lisp魔咒
  17. EventBus详解
  18. Android为TV端助力:adb查找包名位置
  19. 网络IP地址
  20. js 中导出excel 较长数字串会变成科学计数法

热门文章

  1. python-数据
  2. obv15 实例6:如果K线柱过多,ZIG将发生变动,导致明显的OBV15指标被隐藏!
  3. sqlserver 用一个表的值 更新另一个表
  4. Java类访问控制
  5. django 网站的搭建(1)
  6. 3.GDScript(1)概览
  7. 变量part2
  8. html5-边框属性
  9. Java基础语法(二 )
  10. xshell的一些基本操作