To set the number of threads on the Message Queue for Apache RocketMQ client, add a ConsumeThreadNums property when starting the consumer. The example code is as follows:

    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put(PropertyKeyConst.GROUP_ID, "GID_001");
        properties.put(PropertyKeyConst.AccessKey, "xxxxxxxxxxxx");
        properties.put(PropertyKeyConst.SecretKey, "xxxxxxxxxxxx");
         * Set the number of consumer threads to 20.
        Consumer consumer =ONSFactory.createConsumer(properties);
        consumer.subscribe("TestTopic", "*", new MessageListener() {
            public Action consume(Message message, ConsumeContext context) {
                System.out.println("Receive: " + message);
                return Action.CommitMessage;
        System.out.println("Consumer Started");