Use OpenSSL to add support for SSL communication with the server. Script add debug mode support. (#273)

* Modification item:
(1)Add OpenSSL and debug options to the ‘build.sh’ script.
(2)Add the ‘ENABLE_OPENSSL’ macro to cmakelist.txt.
(3)Link the ‘libevent_openssl.a’ static library to support OpenSSL.

* Modification item:
(1)Link static libraries on demand.
(2)Add OpenSSL support and use the macro ‘ENABLE_OPENSSL’ to control OpenSSL compilation blocks.
(3)Inline member defaults. The default value of the inline member is intuitive and error free, and the redundant structure list can be removed, which is also recommended.
(4)Add ignore for vscode configuration in .gitignore.

* Add debugging information in debug mode.

* Modification item:
(1)Add C compiler debugging options.
(2)Remove the compiler debugging option from the child test cmake, which will result in inconsistent behavior between the upper and lower cmakes.
(3)Move the SSL initialization context into the constructor so that it is constructed only once and the memory leak in the last commit code is fixed.
(4)SSL handle is managed to bufferevent without memory management. Forced release will result in double-free.

* Modification item:
(1)Extract SSL context initialization into a function.
(2)Customize std::unique_ptr to manage SSL content and strengthen memory leak management.
(3)Add the default certificate configuration path.
(4)Add environment variables to dynamically modify the certificate configuration path.
(5)Enhance friendly output prompt.
(6)The communication function with the server is verified by self signed certificate.
(7)Asan and lsan tests have been passed.

* Modification item:
(1)Add OpenSSL library and compile script.
(2)Remove the system dynamic library connection, and use the project OpenSSL static library link instead.
(3)Fix some errors in CMakeList.txt.

* Modification item:
    (1)Add OpenSSL library and compile script.
    (2)Remove the system dynamic library connection, and use the project OpenSSL static library link instead.
    (3)Fix some errors in CMakeList.txt.

* Modification item:
(1)Remove the OpenSSL option that controls whether or not it is required.
(2)Remove the ENABLE_OPENSSL macro. OpenSSL is supported by default.
(3)Add API to control whether OpenSSL support is enabled.
(4)Add the ReadProperties utility function.
(5)Add certificate related configuration in the properties configuration file.
(6)Add friendly output prompts.

* By mistake, I wrote a letter ‘t’ short.

* Modification item:
(1)Format the code with the 'format.sh' script.
(2)SSL is turned off by default.

* change openssl static library install path.

* using built-in openssl to compile libevent.

* Modification item:
(1)Moving/Returning temporary object prevents copy elision, which may cause RVO and NRVO are invalid technologies.
(2)Libevent only verifies whether the OpenSSL dynamic library has 'SSL_new' function as the basis for the existence of OpenSSL.
(3)Add a dependent static library to MRI.

* remove comments for code format.

* Fix the missing packing problem of static library packing script under Mac OS. For example, there is buffer. o in libcrypto. a, and buffer. o in libevent_core. a, but the symbols of the two are complementary. The method of using 'ar x'  and 'ar cru' will result in the loss of symbol in one of the above two buffer. o.

* chors(style): format code style for eventloop.
39 files changed
tree: 56083503b198f7c4d688a2737372b362fffe06a8
  1. .github/
  2. .travis/
  3. cmake/
  4. dep/
  5. distribution/
  6. example/
  7. include/
  8. libs/
  9. project/
  10. rpm/
  11. src/
  12. test/
  13. Win32/
  14. .clang-format
  15. .gitignore
  16. .travis.yml
  17. build.sh
  18. CMakeLists.txt
  19. CONTRIBUTING.md
  20. format.sh
  21. LICENSE
  22. NOTICE
  23. package_rocketmq.mri
  24. PULL_REQUEST_TEMPLATE.md
  25. README.md
  26. win32_build.bat
README.md

RocketMQ-Client-CPP

License TravisCI CodeCov GitHub release Twitter Follow

RocketMQ-Client-CPP is the C/C++ client of Apache RocketMQ, a distributed messaging and streaming platform with low latency, high performance and reliability, trillion-level capacity and flexible scalability.

Features

  • produce messages, including normal and delayed messages, synchronously or asynchronously.
  • consume messages, in cluster or broadcast model, concurrently or orderly
  • c and c++ style API.
  • cross-platform, all features are supported on Windows, Linux and Mac OS.
  • automatically rebalanced, both in producing and consuming process.
  • reliability, any downtime broker or name server has no impact on the client.

Build and Install

Linux and Mac OS

note: make sure the following compile tools or libraries have been installed before running the build script build.sh.

  • compile tools:

    • gcc-c++ 4.8.2: c++ compiler while need support C++11
    • cmake 2.8.0: build jsoncpp require it
    • automake 1.11.1: build libevent require it
    • autoconf 2.65: build libevent require it
    • libtool 2.2.6: build libevent require it
  • libraries:

    • bzip2-devel 1.0.6: boost depend it
    • zlib-devel

The build.sh script will automatically download and build the dependency libraries including libevent, json and boost. It will save libraries under rocketmq-client-cpp folder, and then build both static and shared libraries for rocketmq-client. If the dependent libraries are built failed, you could try to build it manually with sources libevent 2.0.22, jsoncpp 0.10.7, boost 1.58.0

If your host is not available to internet to download the three library source files, you can copy the three library source files (release-2.0.22-stable.zip 0.10.7.zip and boost_1_58_0.tar.gz) to rocketmq-client-cpp root dir, then the build.sh will automatically use the three library source files to build rocketmq-client-cpp:

sh build.sh

Finally, both librocketmq.a and librocketmq.so are saved in rocketmq-client-cpp/bin. when using them to build application or library, besides rocketmq you should also link with following libraries -lpthread -lz -ldl -lrt. Here is an example:

g++ -o consumer_example consumer_example.cpp -lrocketmq -lpthread -lz -ldl -lrt

Windows

note: make sure the following compile tools or libraries have been installed before running the build script win32_build.bat:

  • compile tools:
    • vs2015: libevent,jsoncpp,zlib,boost rocket-client require it
    • git: download source code

The build script will automatically download dependent libraries including libevent json and boost to build shared library:

win32_build.bat

If your host is not available to internet to download the four library source files by build script, you can copy the four library source files

zlib-1.2.3-src Extract to $(rocketmq-client-cpp root dir)/thirdparty/zlib-1.2.3-src

libevent-release-2.0.22 Extract to $(rocketmq-client-cpp root dir)/thirdparty/libevent-release-2.0.22

boost_1_58_0 Extract to $(rocketmq-client-cpp root dir)/thirdparty/boost_1_58_0

jsoncpp-0.10.6 Extract to $(rocketmq-client-cpp root dir)/thirdparty/jsoncpp-0.10.6

And then run following command to build x86 rocketmq-client:

win32_build.bat build

to build x64 rocketmq-client:

win32_build.bat build64