AMQP-CPP
========
[![Build Status](https://travis-ci.org/CopernicaMarketingSoftware/AMQP-CPP.svg?branch=master)](https://travis-ci.org/CopernicaMarketingSoftware/AMQP-CPP)
AMQP-CPP is a C++ library for communicating with a RabbitMQ message broker. The
library can be used to parse incoming data from a RabbitMQ server, and to
generate frames that can be sent to a RabbitMQ server.
This library has a layered architecture, and allows you - if you like - to
completely take care of the network layer. If you want to set up and manage the
network connections yourself, the AMQP-CPP library will not make a connection to
RabbitMQ by itself, nor will it create sockets and/or perform IO operations. As
a user of this library, you create the socket connection and implement a certain
interface that you pass to the AMQP-CPP library and that the library will use
for IO operations.
Intercepting this network layer is however optional, the AMQP-CPP library also
comes with a predefined Tcp module that can be used if you trust the AMQP library
to take care of the network handling. In that case, the AMQP-CPP library does
all the system calls to set up network connections and send and receive the data.
This layered architecture makes the library extremely flexible and portable: it
does not necessarily rely on operating system specific IO calls, and can be
easily integrated into any kind of event loop. If you want to implement the AMQP
protocol on top of some [unusual other communication layer](https://tools.ietf.org/html/rfc1149),
this library can be used for that - but if you want to use it with regular TCP
connections, setting it up is just as easy.
AMQP-CPP is fully asynchronous and does not do any blocking (system) calls, so
it can be used in high performance applications without the need for threads.
The AMQP-CPP library uses C++11 features, so if you intend use it, please make
sure that your compiler is up-to-date and supports C++11.
**Note for the reader:** This readme file has a peculiar structure. We start
explaining the pure and hard core low level interface in which you have to
take care of opening socket connections yourself. In reality, you probably want
to use the simpler TCP interface that is being described [later on](#tcp-connections).
ABOUT
=====
This library is created and maintained by Copernica (www.copernica.com), and is
used inside the MailerQ (www.mailerq.com), Yothalot (www.yothalot.com) and
AMQPipe (www.amqpipe.com) applications. MailerQ is a tool for sending large
volumes of email, using AMQP message queues, Yothalot is a big data processing
map/reduce framework and AMQPipe is a tool for high-speed processing messages
between AMQP pipes
Do you appreciate our work and are you looking for high quality email solutions?
Then check out our other commercial and open source solutions:
* Copernica Marketing Suite (www.copernica.com)
* MailerQ on-premise MTA (www.mailerq.com)
* AMQPipe (www.amqpipe.com)
* Responsive Email web service (www.responsiveemail.com)
* SMTPeter cloud based SMTP server (www.smtpeter.com)
* PHP-CPP bridge between PHP and C++ (www.php-cpp.com)
* PHP-JS bridge between PHP and Javascript (www.php-js.com)
* Yothalot big data processor (www.yothalot.com)
INSTALLING
==========
AMQP-CPP comes with an optional Linux-only TCP module that takes care of the
network part required for the AMQP-CPP core library. If you use this module, you
are required to link with `pthread` and `dl`.
There are two methods to compile AMQP-CPP: CMake and Make. CMake is platform portable
and works on all systems, while the Makefile only works on Linux. Building of a shared
library is currently not supported on Windows.
After building there are two relevant files to include when using the library.
File | Include when?
---------------------|--------------------------------------------------------
amqpcpp.h | Always
amqpcpp/linux_tcp.h | If using the Linux-only TCP module
On Windows you are required to define `NOMINMAX` when compiling code that includes public AMQP-CPP header files.
## Using cmake
The CMake file supports both building and installing. You can choose not to use
the install functionality, and instead manually use the build output at `build/bin/`. Keep
in mind that the TCP module is only supported for Linux. An example install method
would be:
```bash
mkdir build
cd build
cmake .. [-DAMQP-CPP_AMQBUILD_SHARED] [-DAMQP-CPP_LINUX_TCP]
cmake --build .. --target install
```
Option | Default | Meaning
-------------------------|---------|-----------------------------------------------------------------------
AMQP-CPP_BUILD_SHARED | OFF | Static lib(ON) or shared lib(OFF)? Shared is not supported on Windows.
AMQP-CPP_LINUX_TCP | OFF | Should the Linux-only TCP module be built?
## Using make
Compiling and installing AMQP-CPP with make is as easy as running `make` and
then `make install`. This will install the full version of AMQP-CPP, including
the system specific TCP module. If you do not need the additional TCP module
(because you take care of handling the network stuff yourself), you can also
compile a pure form of the library. Use `make pure` and `make install` for that.
When you compile an application that uses the AMQP-CPP library, do not
forget to link with the library. For gcc and clang the linker flag is -lamqpcpp.
If you use the fullblown version of AMQP-CPP (with the TCP module), you also
need to pass the -lpthread and -ldl linker flags, because the TCP module uses a
thread for running an asynchronous and non-blocking DNS hostname lookup, and it
may dynamically look up functions from the openssl library if a secure connection
to RabbitMQ has to be set up.
HOW TO USE AMQP-CPP
===================
As we mentioned above, the library can be used in a network-agnostic fashion.
It then does not do any IO by itself, and you need to pass an object to the
library that the library can use for IO. So, before you start using the
library, you first you need to create a class that extends from the
ConnectionHandler base class. This is a class with a number of methods that are
called by the library every time it wants to send out data, or when it needs to
inform you that an error occured.
````c++
#include <amqpcpp.h>
class MyConnectionHandler : public AMQP::ConnectionHandler
{
/**
* Method that is called by the AMQP library every time it has data
* available that should be sent to RabbitMQ.
* @param connection pointer to the main connection object
* @param data memory buffer with the data that should be sent to RabbitMQ
* @param size size of the buffer
*/
virtual void onData(AMQP::Connection *connection, const char *data, size_t size)
{
// @todo
// Add your own implementation, for example by doing a call to the
// send() system call. But be aware that the send() call may not
// send all data at once, so you also need to take care of buffering
// the bytes that could not immediately be sent, and try to send
// them again when the socket becomes writable again
}
/**
* Method that is called by the AMQP library when the login attempt
* succeeded. After this method has been called, the connection is ready
* to use.
* @param connection The connection that can now be used
*/
virtual void onConnected(AMQP::Connection *connection)
{
// @todo
// add your own implementation, for example by creating a channel
// instance, and start publishing or consuming
}
/**
* Method that is called by the AMQP library when a fatal error occurs
* on the connection, for example because data received from RabbitMQ
* could not be recognized.
* @param connection The connection on which the error occured
* @param message A human readable error message
没有合适的资源?快使用搜索试试~ 我知道了~
MQTT C++客户端
共192个文件
h:151个
cpp:24个
gitignore:4个
3星 · 超过75%的资源 需积分: 45 169 下载量 144 浏览量
2018-05-06
12:04:49
上传
评论
收藏 240KB ZIP 举报
温馨提示
AMQP的原始用途只是为金融界提供一个可以彼此协作的消息协议,而现在的目标则是为通用消息队列架构提供通用构建工具。因此,面向消息的中间件(MOM)系统,例如发布/订阅队列,没有作为基本元素实现。反而通过发送简化的AMQ实体,用户被赋予了构建例如这些实体的能力。这些实体也是规范的一部分,形成了在线路层协议顶端的一个层级:AMQP模型。这个模型统一了消息模式,诸如之前提到的发布/订阅,队列,事务以及流数据,并且添加了额外的特性,例如更易于扩展,基于内容的路由。
资源推荐
资源详情
资源评论
收起资源包目录
MQTT C++客户端 (192个子文件)
.clang_complete 43B
channelimpl.cpp 25KB
receivedframe.cpp 16KB
connectionimpl.cpp 11KB
openssl.cpp 7KB
myconnection.cpp 6KB
tcpconnection.cpp 5KB
table.cpp 4KB
array.cpp 3KB
libev.cpp 2KB
deferredreceiver.cpp 2KB
libuv.cpp 2KB
field.cpp 2KB
deferredget.cpp 2KB
deferredpublisher.cpp 2KB
deferredextreceiver.cpp 2KB
libboostasio.cpp 1KB
deferredconsumer.cpp 1KB
libevent.cpp 1KB
address.cpp 901B
flags.cpp 887B
main.cpp 822B
deferredcancel.cpp 751B
watchable.cpp 416B
table.cpp 249B
.gitignore 191B
.gitignore 6B
.gitignore 6B
.gitignore 4B
channel.h 24KB
channelimpl.h 22KB
libboostasio.h 19KB
sslconnected.h 15KB
metadata.h 12KB
connectionimpl.h 11KB
tcpconnected.h 10KB
libev.h 8KB
address.h 8KB
sslhandshake.h 8KB
deferredconsumer.h 8KB
deferredget.h 7KB
tcpresolver.h 7KB
tcpoutbuffer.h 7KB
sslshutdown.h 7KB
deferred.h 7KB
table.h 6KB
libuv.h 6KB
connection.h 6KB
deferredpublisher.h 6KB
receivedframe.h 6KB
numericfield.h 5KB
tcpconnection.h 5KB
decimalfield.h 5KB
fieldproxy.h 5KB
libevent.h 5KB
tcpstate.h 5KB
basicdeliverframe.h 5KB
array.h 5KB
connectionstartframe.h 5KB
tcphandler.h 5KB
basicgetokframe.h 5KB
connectionhandler.h 5KB
exchangedeclareframe.h 4KB
basicconsumeframe.h 4KB
queuedeclareframe.h 4KB
entityimpl.h 4KB
basicreturnframe.h 4KB
function.h 4KB
stringfield.h 4KB
message.h 4KB
booleanset.h 4KB
connectioncloseframe.h 4KB
queuebindframe.h 4KB
channelcloseframe.h 4KB
connectiontuneframe.h 4KB
basicpublishframe.h 4KB
extframe.h 3KB
outbuffer.h 3KB
tcpinbuffer.h 3KB
exchangebindframe.h 3KB
exchangeunbindframe.h 3KB
myconnection.h 3KB
endian.h 3KB
basicheaderframe.h 3KB
connectionstartokframe.h 3KB
login.h 3KB
protocolheaderframe.h 3KB
queueunbindframe.h 3KB
queuedeclareokframe.h 3KB
queuedeleteframe.h 3KB
field.h 3KB
deferredreceiver.h 3KB
stack_ptr.h 3KB
exchangedeleteframe.h 3KB
passthroughbuffer.h 3KB
bytebuffer.h 3KB
deferredqueue.h 3KB
bodyframe.h 3KB
connectiontuneokframe.h 3KB
deferreddelete.h 3KB
共 192 条
- 1
- 2
资源评论
- WANGZHEN`2018-12-19先下载看看能不能用
- mrliangzhu2018-06-27下载看看能不能用
- a6724356252018-10-20为什么没附加到工程里。
xinlan0711
- 粉丝: 1
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功