Send and receive messages with the Apache RocketMQ 5.x SDK for C++. The following table lists the sample code for each message type and consumer pattern.
Sample code by message type
Parameters
Replace the following parameters in the sample code with your actual values before you run the code.
| Parameter | Example | Description |
|---|---|---|
access_point | rmq-cn-xxx.{regionId}.rmq.aliyuncs.com:8080 | The endpoint of your ApsaraMQ for RocketMQ instance. Specify the public endpoint for Internet access or the VPC endpoint for VPC access. For more information, see Obtain the endpoint of an instance. |
topic | normal_test | The topic to which messages are sent or from which messages are consumed. Create the topic in advance. For more information, see Create a topic. |
group | GID_test | The consumer group for message consumption. Create the consumer group in advance. For more information, see Create a consumer group. |
access_key | 1XVg0hzgKm****** | The username of your ApsaraMQ for RocketMQ instance. Required for Internet access. For VPC access, required only if the instance is serverless and the authentication-free in VPCs feature is disabled. For more information, see Obtain the username and password of an instance. |
access_secret | ijSt8rEc45****** | The password of your ApsaraMQ for RocketMQ instance. Required for Internet access. For VPC access, required only if the instance is serverless and the authentication-free in VPCs feature is disabled. For more information, see Obtain the username and password of an instance. |