Linux Build and use Rabbitmq-c

Source: Internet
Author: User
Tags rabbitmq amq

1) According to the method described here, first install the CMake
2) find here download link, download Rabbitmq-c package
3) Unzip, enter the extracted directory

4) mkdir build && CD build # This step is to create a build subdirectory in the root directory of the rabbitmq-c
5) CMake. # This step is to let cmake according to: /cmakelist.txt, the CMakeList.txt created makefile file in the root directory of rabbitmq-c, the makefile file will be created in the build directory
6) CMake--build. # This step is the real build rabbitmq-c library, note, do not miss the end of the point '. '

When finished, the LIBRABBITMQ, examples, and tests subdirectories appear under the build directory. Where LIBRABBITMQ contains files such as generated librabbitmq.so, examples contains Amqp_bind, Amqp_consumer, Amqp_exchange_declare, Amqp_listen, AMQP _listenq, Amqp_producer, Amqp_rpc_sendstring_client, amqp_sendstring, and Amqp_unbind executables.

Here are rabbitmq-c example instructions for use, and a brief description of using LIBRABBITMQ.


error message about Amqp_open_socket Connection refused


The reason for this is that the following sentence is mentioned in the use note:

Arrange for a RabbitMQ or other AMQP server to is running on localhost at TCP port number 5672.

That is, before running example, you need to start the RABBITMQ service, listen to port 5672 on localhost, and then the following actions will work correctly. Otherwise, you will encounter the error "Opening Socket:connection refused"

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 1Frame Type 1, channel 1Method Amqp_basic_deliver_methoddelivery 1, Exchange Amq.direct Routingkey Testcontent-typ E:text/plain----00000000:68 6C 6C 6F, 6f:72 6C                 , hello world0000000b:

in fact,./examples/amqp_listen localhost 5672 amq.direct test is not really a RABBITMQ service and listens on localhost : 5672, but simulates the true RABBITMQ server: If you receive the correct data on port 5672, the appropriate information is printed. In fact, this simulation of the server can not,./examples/amqp_sendstring localhost 5672 amq.direct test "Hello World" can also be successfully sent to localhost:5672 data.

Linux Build and use Rabbitmq-c

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.