XUtils

rabbitmq-c

Client library for [RabbitMQ](https://www.rabbitmq.com/). [`Expat`](https://directory.fsf.org/wiki/License:Expat)


RabbitMQ C AMQP client library

Build Status

Coverage Status

Fuzzing Status

OpenSSF Best Practices

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-c-users and cross-posted to rabbitmq-users.

Latest Stable Version

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

Documentation

API documentation for v0.8.0+ can viewed from:

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

Getting started

Building and installing

Building RabbitMQ - Using vcpkg

You can download and install RabbitMQ using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install librabbitmq

The RabbitMQ port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

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:

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.


Articles

  • coming soon...