Skip to content
This repository

RabbitMQ C client

This branch is 0 commits ahead and 0 commits behind master

Use poll(2) for timeouts on socket

Use poll(2) instead of select(2) to do timeout operations on sockets. This helps
with the situation where the fd is larger than FD_MAXSIZE.

Fixes #168
latest commit a78aa8ab90
Alan Antonuk authored
Octocat-spinner-32 cmake Add GNUInstallDirs.cmake module November 05, 2013
Octocat-spinner-32 codegen @ 0a95a69 Initial connection.blocked/unblocked support December 15, 2013
Octocat-spinner-32 coverity Add Coverity model file June 18, 2013
Octocat-spinner-32 docs Document public API August 13, 2013
Octocat-spinner-32 etc Cleanup Win32 artifacts May 17, 2012
Octocat-spinner-32 examples FIX: destroy amqp_envelope_t in consumer example August 20, 2013
Octocat-spinner-32 librabbitmq Use poll(2) for timeouts on socket April 14, 2014
Octocat-spinner-32 m4 Update polarssl.m4 April 09, 2013
Octocat-spinner-32 tests CMake: Add -DHAVE_CONFIG_H to tests/*.c April 13, 2014
Octocat-spinner-32 tools Honor delivery mode value from command line December 30, 2013
Octocat-spinner-32 vms OpenVMS MMS build system June 26, 2013
Octocat-spinner-32 .astyle Formatted source code with astyle utilty April 08, 2013
Octocat-spinner-32 .gitattributes Adding .gitattributes October 24, 2012
Octocat-spinner-32 .gitignore [openssl] Support wildcard hostname verification March 04, 2014
Octocat-spinner-32 .gitmodules Use https for codegen submodule URI protocol January 15, 2013
Octocat-spinner-32 .hgignore New example: amqp_rpc_sendstring_client. The client sends a plain tex… October 05, 2012
Octocat-spinner-32 .travis.yml Fixes for travis-ci configuration. April 13, 2014
Octocat-spinner-32 AUTHORS Fix remaining mentions of the defunct tonyg@rabbitmq.com address March 02, 2011
Octocat-spinner-32 CMakeLists.txt Preparation for v0.5.0 release January 29, 2014
Octocat-spinner-32 CONTRIBUTING.md Adding a CONTRIBUTING.md document November 07, 2012
Octocat-spinner-32 ChangeLog.md Preparation for v0.5.0 release January 29, 2014
Octocat-spinner-32 LICENSE-MIT Updating license year April 08, 2013
Octocat-spinner-32 Makefile.am [openssl] Support wildcard hostname verification March 04, 2014
Octocat-spinner-32 README-win32.md Update README.md to reflect changes in build procedure January 17, 2013
Octocat-spinner-32 README.md Preparation for v0.5.0 release January 29, 2014
Octocat-spinner-32 README.vms OpenVMS MMS build system June 26, 2013
Octocat-spinner-32 THANKS Credit recent contributors February 07, 2011
Octocat-spinner-32 TODO Remove note about amqp_pool_alloc. April 16, 2010
Octocat-spinner-32 configure.ac Preparation for v0.5.0 release January 29, 2014
Octocat-spinner-32 descrip.mms OpenVMS MMS build system June 26, 2013
Octocat-spinner-32 librabbitmq.pc.in CMake: correct generation of librabbitmq.pc August 20, 2013
README.md

RabbitMQ C AMQP client library

Build Status

Introduction

This is a C-language AMQP client library for use with v2.0+ of the RabbitMQ broker.

Announcements regarding the library are periodically made on the rabbitmq-discuss mailing list:

Latest Stable Version

The latest stable release of rabbitmq-c is v0.5.0. A complete list of changes can be found in the Change Log

The v0.5.0 source tarball can be downloaded from:

https://github.com/alanxz/rabbitmq-c/releases/download/v0.5.0/rabbitmq-c-0.5.0.tar.gz

API documentation for v0.5.0+ can viewed from:

http://alanxz.github.io/rabbitmq-c/docs/0.5.0/

Getting started

Building and installing

Prereqs:

  • CMake v2.6 or better
  • A C compiler (GCC 4.4+, clang, and MSVC are test. Other compilers may also work)
  • Optionally OpenSSL v0.9.8+ to enable support for connecting to RabbitMQ over SSL/TLS
  • Optionally POpt to build some handy command-line tools.
  • Optionally XmlTo to build man pages for the handy command-line tools
  • Optionally Doxygen to build developer API documentation.

After downloading and extracting the source from a tarball to a directory. ([see above][Latest Stable Version]), the commands to build rabbitmq-c on most systems are:

mkdir build && cd build
cmake ..
cmake --build [--config Release] .

The --config Release flag should be used in multi-configuration generators e.g., Visual Studio or XCode.

It is also possible to point the CMake GUI tool at the CMakeLists.txt in the root of the 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 . [--config Release] --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=ON/OFF toggles building the examples. ON by default.
  • BUILD_SHARED_LIBS=ON/OFF toggles building rabbitmq-c as a shared library. ON by default.
  • BUILD_STATIC_LIBS=ON/OFF toggles building rabbitmq-c as a static library. OFF by default.
  • BUILD_TESTS=ON/OFF toggles building test code. ON by default.
  • BUILD_TOOLS=ON/OFF toggles building the command line tools. By default this is ON if the build system can find the POpt header and library.
  • BUILD_TOOLS_DOCS=ON/OFF toggles building the man pages for the command line tools. By default this is ON if BUILD_TOOLS is ON and the build system can find the XmlTo utility.
  • ENABLE_SSL_SUPPORT=ON/OFF toggles building rabbitmq-c with SSL support. By default this is ON if the OpenSSL headers and library can be found.
  • ENABLE_THREAD_SAFETY=ON/OFF toggles OpenSSL thread-safety. By default this is ON
  • BUILD_API_DOCS=ON/OFF - toggles building the Doxygen API documentation, by default this is OFF

autotools

For legacy purposes, a GNU autotools based build system is also maintained. The required utilities you need are autoconf v2.59+, automake v1.9+, libtool v2.2+, and pkg-config.

Then the standard autotools build procedure will build rabbitmq-c:

autoreconf -i
./configure
make
make install

Running the examples

Arrange for a RabbitMQ or other AMQP server to be running on localhost 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's terminal 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 of the librabbitmq library.

Threading

You cannot share a socket, an amqp_connection_state_t, or a channel between threads using librabbitmq. The librabbitmq library 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.

Something went wrong with that request. Please try again.