Fetching contributors…
Cannot retrieve contributors at this time
89 lines (60 sloc) 2.6 KB
# RabbitMQ C AMQP client library
## Introduction
This is a C-language AMQP client library for use with AMQP servers
speaking protocol versions 0-9-1.
- <>
- <>
- <>
Announcements regarding the library are periodically made on the
RabbitMQ mailing list and on the RabbitMQ blog.
- <>
- <>
## Retrieving the code
In addition to the source code for this library, you will require a
copy of `rabbitmq-codegen`. Here is a short `sh` script for retrieving
the necessary pieces:
hg clone
hg clone
You will also need a recent python with the simplejson module
installed, and the GNU autotools (autoconf, automake, libtool etc).
## Building the code
Once you have all the prerequisites, change to the `rabbitmq-c`
directory and run
autoreconf -i
to run the GNU autotools and generate the configure script, followed
to build the `librabbitmq` library and the example programs.
## 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:
Result 1
Frame type 1, channel 1
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.
### 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 `pthread`ed
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.