Blame README.md

Packit 12c978
# RabbitMQ C AMQP client library
Packit 12c978
Packit 12c978
[![Build Status](https://secure.travis-ci.org/alanxz/rabbitmq-c.png?branch=master)](http://travis-ci.org/alanxz/rabbitmq-c)
Packit 12c978
Packit 12c978
[![Coverage Status](https://coveralls.io/repos/github/alanxz/rabbitmq-c/badge.svg?branch=master)](https://coveralls.io/github/alanxz/rabbitmq-c?branch=master)
Packit 12c978
Packit 12c978
## Introduction
Packit 12c978
Packit 12c978
This is a C-language AMQP client library for use with v2.0+ of the
Packit 12c978
[RabbitMQ](http://www.rabbitmq.com/) broker.
Packit 12c978
Packit 12c978
 - <http://github.com/alanxz/rabbitmq-c>
Packit 12c978
Packit 12c978
Announcements regarding the library are periodically made on the
Packit 12c978
rabbitmq-c-users and cross-posted to rabbitmq-users.
Packit 12c978
Packit 12c978
 - <https://groups.google.com/forum/#!forum/rabbitmq-c-users>
Packit 12c978
 - <https://groups.google.com/forum/#!forum/rabbitmq-users>
Packit 12c978
Packit 12c978
## Latest Stable Version
Packit 12c978
Packit 12c978
The latest stable release of rabbitmq-c can be found at:
Packit 12c978
Packit 12c978
 - <https://github.com/alanxz/rabbitmq-c/releases/latest>
Packit 12c978
Packit 12c978
## Documentation
Packit 12c978
Packit 12c978
API documentation for v0.8.0+ can viewed from:
Packit 12c978
Packit 12c978
<http://alanxz.github.io/rabbitmq-c/docs/0.8.0/>
Packit 12c978
Packit 12c978
## Getting started
Packit 12c978
Packit 12c978
### Building and installing
Packit 12c978
Packit 12c978
#### Prereqs:
Packit 12c978
- [CMake v2.6 or better](http://www.cmake.org/)
Packit 12c978
- A C compiler (GCC 4.4+, clang, and MSVC are test. Other compilers may also
Packit 12c978
  work)
Packit 12c978
- *Optionally* [OpenSSL](http://www.openssl.org/) v0.9.8+ to enable support for
Packit 12c978
  connecting to RabbitMQ over SSL/TLS
Packit 12c978
- *Optionally* [POpt](http://freecode.com/projects/popt) to build some handy
Packit 12c978
  command-line tools.
Packit 12c978
- *Optionally* [XmlTo](https://fedorahosted.org/xmlto/) to build man pages for
Packit 12c978
  the handy command-line tools
Packit 12c978
- *Optionally* [Doxygen](http://www.stack.nl/~dimitri/doxygen/) to build
Packit 12c978
  developer API documentation.
Packit 12c978
Packit 12c978
After downloading and extracting the source from a tarball to a directory
Packit 12c978
([see above](#latest-stable-version)), the commands to build rabbitmq-c on most
Packit 12c978
systems are:
Packit 12c978
Packit 12c978
    mkdir build && cd build
Packit 12c978
    cmake ..
Packit 12c978
    cmake --build [--config Release] .
Packit 12c978
Packit 12c978
The --config Release flag should be used in multi-configuration generators e.g.,
Packit 12c978
Visual Studio or XCode.
Packit 12c978
Packit 12c978
It is also possible to point the CMake GUI tool at the CMakeLists.txt in the root of
Packit 12c978
the source tree and generate build projects or IDE workspace
Packit 12c978
Packit 12c978
Installing the library and optionally specifying a prefix can be done with:
Packit 12c978
Packit 12c978
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
Packit 12c978
    cmake --build . [--config Release] --target install
Packit 12c978
Packit 12c978
More information on CMake can be found on its FAQ (http://www.cmake.org/Wiki/CMake_FAQ)
Packit 12c978
Packit 12c978
Other interesting flags that can be passed to CMake:
Packit 12c978
Packit 12c978
* `BUILD_EXAMPLES=ON/OFF` toggles building the examples. ON by default.
Packit 12c978
* `BUILD_SHARED_LIBS=ON/OFF` toggles building rabbitmq-c as a shared library.
Packit 12c978
   ON by default.
Packit 12c978
* `BUILD_STATIC_LIBS=ON/OFF` toggles building rabbitmq-c as a static library.
Packit 12c978
   OFF by default.
Packit 12c978
* `BUILD_TESTS=ON/OFF` toggles building test code. ON by default.
Packit 12c978
* `BUILD_TOOLS=ON/OFF` toggles building the command line tools. By default
Packit 12c978
   this is ON if the build system can find the POpt header and library.
Packit 12c978
* `BUILD_TOOLS_DOCS=ON/OFF` toggles building the man pages for the command line
Packit 12c978
   tools. By default this is ON if BUILD_TOOLS is ON and the build system can
Packit 12c978
   find the XmlTo utility.
Packit 12c978
* `ENABLE_SSL_SUPPORT=ON/OFF` toggles building rabbitmq-c with SSL support. By
Packit 12c978
   default this is ON if the OpenSSL headers and library can be found.
Packit 12c978
* `BUILD_API_DOCS=ON/OFF` - toggles building the Doxygen API documentation, by
Packit 12c978
   default this is OFF
Packit 12c978
Packit 12c978
## Running the examples
Packit 12c978
Packit 12c978
Arrange for a RabbitMQ or other AMQP server to be running on
Packit 12c978
`localhost` at TCP port number 5672.
Packit 12c978
Packit 12c978
In one terminal, run
Packit 12c978
Packit 12c978
    ./examples/amqp_listen localhost 5672 amq.direct test
Packit 12c978
Packit 12c978
In another terminal,
Packit 12c978
Packit 12c978
    ./examples/amqp_sendstring localhost 5672 amq.direct test "hello world"
Packit 12c978
Packit 12c978
You should see output similar to the following in the listener's
Packit 12c978
terminal window:
Packit 12c978
Packit 12c978
    Delivery 1, exchange amq.direct routingkey test
Packit 12c978
    Content-type: text/plain
Packit 12c978
    ----
Packit 12c978
    00000000: 68 65 6C 6C 6F 20 77 6F : 72 6C 64                 hello world
Packit 12c978
    0000000B:
Packit 12c978
Packit 12c978
## Writing applications using `librabbitmq`
Packit 12c978
Packit 12c978
Please see the `examples` directory for short examples of the use of
Packit 12c978
the `librabbitmq` library.
Packit 12c978
Packit 12c978
### Threading
Packit 12c978
Packit 12c978
You cannot share a socket, an `amqp_connection_state_t`, or a channel
Packit 12c978
between threads using `librabbitmq`. The `librabbitmq` library is
Packit 12c978
built with event-driven, single-threaded applications in mind, and
Packit 12c978
does not yet cater to any of the requirements of `pthread`ed
Packit 12c978
applications.
Packit 12c978
Packit 12c978
Your applications instead should open an AMQP connection (and an
Packit 12c978
associated socket, of course) per thread. If your program needs to
Packit 12c978
access an AMQP connection or any of its channels from more than one
Packit 12c978
thread, it is entirely responsible for designing and implementing an
Packit 12c978
appropriate locking scheme. It will generally be much simpler to have
Packit 12c978
a connection exclusive to each thread that needs AMQP service.