Skip to content
RabbitMQ C client
C CMake Python M4 Makefile Shell
Pull request Compare This branch is 515 commits ahead, 2 commits behind rabbitmq:master.
Latest commit edaccdd Apr 21, 2016 @jstefanski jstefanski committed with Add NORETURN macro for MSVC
Failed to load latest commit information.
cmake CMake: Remove install_pdb macro. Apr 9, 2016
codegen @ 0a95a69 Initial connection.blocked/unblocked support Dec 15, 2013
coverity Coverity: update model to include more abort funcs Dec 25, 2015
docs Document public API Aug 13, 2013
examples Fix: small warning fixes. Apr 9, 2016
librabbitmq Add NORETURN macro for MSVC Apr 21, 2016
m4 Lib: remove unmaintained SSL backends Oct 13, 2015
tests Fix: small warning fixes. Apr 10, 2016
tools Squash warnings about static initializers in tools. May 3, 2015
.clang-format Add clang-format configuration file. Jul 20, 2014
.gitattributes Adding .gitattributes Oct 24, 2012
.gitignore Adding build/ in .gitignore Dec 12, 2015
.gitmodules Use https for codegen submodule URI protocol Jan 15, 2013
.travis.yml CI: add clang-analyzer build on travis. Jan 13, 2016 ycm: add -std=gnu90 -DHAVE_POLL flags to ycm config. Jun 1, 2015
AUTHORS Fix remaining mentions of the defunct address Mar 2, 2011
CMakeLists.txt Bumping revision for development. Apr 10, 2016 Adding a document Nov 7, 2012 Preparation for v0.8.0 release. Apr 9, 2016
LICENSE-MIT Updating license year Apr 8, 2013 Lib: Add robust OpenSSL hostname validation. Nov 8, 2015 Preparation for v0.8.0 release. Apr 10, 2016
THANKS Credit recent contributors Feb 7, 2011
TODO Remove note about amqp_pool_alloc. Apr 16, 2010
appveyor.yml CI: bump OpenSSL version to 1.0.2g. Mar 7, 2016 Bumping revision for development. Apr 11, 2016 CMake: correct generation of librabbitmq.pc Aug 20, 2013 CI: add clang-analyzer build on travis. Jan 13, 2016

RabbitMQ C AMQP client library

Build Status


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-users mailing list:

Latest Stable Version

The latest stable release of rabbitmq-c can be found at:


API documentation for v0.8.0+ can viewed from:

Getting started

Building and installing


  • 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 (

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


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
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 test

In another terminal,

./examples/amqp_sendstring localhost 5672 test "hello world"

You should see output similar to the following in the listener's terminal window:

Delivery 1, exchange routingkey test
Content-type: text/plain
00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64                 hello world

Writing applications using librabbitmq

Please see the examples directory for short examples of the use of the librabbitmq library.


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.