Demo project setting includes the following steps:
Prerequisite: If JDK is not installed on your local disk, please download and install it first.
In IDEA, select Import Project, and select folder mq-demo-master.
Select Import Type.
Click Next until the import is completed. Dependent JAR package needs to be downloaded for the demo project, so the import process will take 2-3 minutes.
Create Topic, Producer ID (PID), and Consumer ID (CID) in the MQ console.
Log on to the MQ console.
Select Internet region (default), click Create Topic on the right side, enter topic name (as unique as possible to prevent repetition), select message type, enter description, and click OK.
Click Create Producer in the Actions column to create a producer ID.
Click Create Consumer in the Actions column to create a consumer ID.
For detailed information, see Step 2: Create resources.
3 files need to be configured: MqConfig class, producer.xml, and consumer.xml.
Configure MqConfig class as follows.
- public static final String TOPIC = “the topic just created”;
- public static final String PRODUCER_ID = “the PID just created”;
- public static final String CONSUMER_ID = “the CID just created”;
- public static final String ACCESS_KEY = “AK of your Alibaba Cloud Account”;
- public static final String SECRET_KEY = “SK of your Alibaba Cloud Account”;
Log on your Alibaba Cloud Account, and click AccessKeys to obtain accesskeys. AK refers to Access Key ID and SK Access Key Secret.
Note: You can also use the AK and SK of the RAM sub-account if it is authorized in the MQ console when the topic is created for the primary account.