windows下rabbitmq-c編譯(帶openssl、無需MinGW)

來源:互聯網
上載者:User

標籤:視窗   window   線程   cmake   instead   using   connect   慢慢   否則   

因為項目原因,需要使用到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\DebugD:\rabbitmq-c-0.8.0-build\examples\Debug>amqp_listen localhost 5672 amq.direct testDelivery 1, exchange amq.direct routingkey testContent-type: text/plain----00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64                 hello world0000000B:Delivery 2, exchange amq.direct routingkey testContent-type: text/plain----00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64                 hello world0000000B:Delivery 3, exchange amq.direct routingkey testContent-type: text/plain----00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64                 hello world0000000B: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\DebugD:\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了。

windows下rabbitmq-c編譯(帶openssl、無需MinGW)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.