edit-icon download-icon

Set up the project

Last Updated: Jun 20, 2018

Demo project setting includes the following steps:

Import MQ Demo Project to IDEA

Prerequisite: If JDK is not installed on your local disk, please download and install it first.

  1. In IDEA, select Import Project, and select folder mq-demo-master.

    IDEA Import Demo

  2. Select Import Type.


  3. 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 MQ Resources

Create Topic, Producer ID (PID), and Consumer ID (CID) in the MQ console.

  1. Log on to the MQ console.

  2. 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.

  3. Click Create Producer in the Actions column to create a producer ID.

  4. Click Create Consumer in the Actions column to create a consumer ID.

For detailed information, see Step 2: Create resources.

Configure MQ Demo

3 files need to be configured: MqConfig class, producer.xml, and consumer.xml.

  1. 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.

  2. Configure producer.xml.

    Configure P-XML

  3. Configure consumer.xml.

    Configure C-XML

Thank you! We've received your feedback.