Introduction
This is a C-language AMQP client library for use with AMQP serversspeaking protocol versions 0-9-1.
Announcements regarding the library are periodically made on theRabbitMQ mailing list and on the RabbitMQ blog.
API Documentation (rather incomplete at this point) can be found:
Latest Stable Version
The latest stable version of rabbitmq-c is v0.3.0 and can be downloaded from:https://github.com/alanxz/rabbitmq-c/archive/rabbitmq-c-v0.3.0.zip
Building and installing using CMake
The rabbitmq-c library is built using CMake v2.6+ (http://www.cmake.org) on allplatforms.
The library itself requires no external dependancies.
OPTIONALLY: A set of command line tools used to interact with the broker areincluded and require the Popt library (http://freecode.com/projects/popt).A matching set of man pages have been written in DocBook format and needthe XmlTo (https://fedorahosted.org/xmlto/) utility to function correctly.
On most systems the commands to build rabbitmq-c are:
mkdir build && cd build
cmake ..
cmake --build .
It is also possible to point the CMake GUI tool at the CMakeLists.txt in the root ofthe source tree and generate build projects or IDE workspace
Installing the library and optionally specifying a prefix can be done with:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
cmake --build . --target install
More information on CMake can be found on its FAQ (http://www.cmake.org/Wiki/CMake_FAQ)
Other interesting flags that can be passed to CMake:
BUILD_EXAMPLES- builds the example codeBUILD_TOOLSbuilds some command line tools for interacting with the brokerBUILD_TOOLS_DOCSis enabled and XmlTo is foundBUILD_SHARED_LIBS- build rabbitmq-c as a shared libraryBUILD_STATIC_LIBS- build rabbitmq-c as a static library
Building and installing using autotools
For legacy purposes, a GNU autotools based build system is also maintained. The requiredutilities you need are autoconf v2.59+, automake v1.9+, libtool v2.2+, and pkg-config.
From a fresh tarball you will need to run reconf:
autoreconf -i
Then the standard autotools build procedure will build rabbitmq-c:
./configure
make
make install
Running the examples
Arrange for a RabbitMQ or other AMQP server to be running onlocalhost at TCP port number 5672.
In one terminal, run
./examples/amqp_listen localhost 5672 amq.direct test
In another terminal,
./examples/amqp_sendstring localhost 5672 amq.direct test "hello world"
You should see output similar to the following in the listener'sterminal window:
Result 1
Frame type 1, channel 1
Method AMQP_BASIC_DELIVER_METHOD
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:
Writing applications using librabbitmq
Please see the examples directory for short examples of the use ofthe librabbitmq library.
Threading
You cannot share a socket, an amqp_connection_state_t, or a channelbetween threads using librabbitmq. The librabbitmq library isbuilt with event-driven, single-threaded applications in mind, anddoes not yet cater to any of the requirements of pthreadedapplications.
Your applications instead should open an AMQP connection (and anassociated socket, of course) per thread. If your program needs toaccess an AMQP connection or any of its channels from more than onethread, it is entirely responsible for designing and implementing anappropriate locking scheme. It will generally be much simpler to havea connection exclusive to each thread that needs AMQP service.
本文介绍了一个C语言实现的AMQP客户端库rabbitmq-c,适用于AMQP 0-9-1协议版本。该库提供了与RabbitMQ等消息中间件交互的功能,并包含了构建和安装指南、API文档链接及示例代码。
1811

被折叠的 条评论
为什么被折叠?



