This topic describes the preparations, instructions, and precautions for accessing Message Queue for Apache RocketMQ by using C++ SDK v2.0.0 so that you can use the C++ SDK to send and subscribe to messages.
- This topic describes only the C++ SDK v2.0.0. For more information about how to upgrade from the current C++ SDK v1.x.x to the C++ SDK v2.0.0, see Prepare the environment (v1.x. x).
- The topic and group ID in the code must have been created in the Message Queue for Apache RocketMQ (RocketMQ) console first. Application users can specify message tags. For more information about how to create a message tag, see Step 2: Create resources.
- An application that uses the Message Queue for Apache RocketMQ service must have been deployed on an Elastic Compute Service (ECS) instance of Alibaba Cloud.
Currently, the C++ SDK v2.0.0 supports only the Linux CentOS 6 (RHEL 6) and CentOS 7 (RHEL 7) series. For more information about the download link for the C++ SDK, see Release notes.
After downloading the C++ SDK, select the version corresponding to your operating system kernel for decompression. The following directory structure is generated:
Contains examples for sending normal messages, one-way messages, and ordered messages, as well as for consuming normal messages and ordered messages. This directory also contains
CMakeList.txtthat is used to compile and manage
Contains header files required by your own program.
Contains dynamic libraries based on x86_64, which are the interface library (libonsclient4cpp.so) and the core library (librocketmq_client_core.so).
Contains a list of solved problems and newly added features in the new version.
Linux C ++ SDK dynamic library solutions
Since June 28, 2019, the new SDK version has only provided dynamic library solutions. Message Queue for Apache RocketMQ The library file of [******] is stored in the
lib/ directory. Your customer needs to link
libonsclient4cpp.so when generating executable files. As
demos has introduced the features of C++ 11 and uses CMake for management, you need to install CMake 3.0 or later and g++ 4.8 or later in advance.
-D_GLIBCXX_USE_CXX11_ABI=0option when compiling a link.
You can use
demos as follows:
cd aliyun-mq-linux-cpp-sdk //The path to which the downloaded SDK package is decompressed. cd demos //Go to the demos directory and modify the demos file by entering information such as the topic and key that you created in the RocketMQ console. cmake. //Check the dependencies and generate a compilation script. make //Perform compilation. cd bin //Run the program in the directory where the generated executable file resides.