Repository: apache/rocketmq-spring (Java)

Issue:
Bug in ConsumeMessageService#updateCorePoolSize" not support increase coreSize
The issue tracker is **ONLY** used for bug report and feature request. 

Any question or RocketMQ proposal please use our [mailing lists](http://rocketmq.apache.org/about/contact/).

**BUG REPORT**

1. Please describe the issue you observed:
The annotation RocketMQMessageListener use consumeThreadNumber as consumeExecutor coreSize and maximumSize,which makes method "ConsumeMessageService#updateCorePoolSize" not support increase coreSize.
<img width="805" alt="image" src="https://user-images.githubusercontent.com/40804675/227460125-52f0a9a8-66a8-406d-9f44-3a8f54b34048.png">
<img width="824" alt="image" src="https://user-images.githubusercontent.com/40804675/227458257-e917b9c8-d93d-48fe-bfe0-a072167141c1.png">
- What did you do (The steps to reproduce)?
1.use @RocketMQMessageListener declare a listener
2.implement RocketMQPushConsumerLifecycleListener#prepareStart to hold consumer instance.
3.call the consumer updateCorePoolSize
corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax() is always false,because same value.
- What did you expect to see?
ConsumeMessageService#updateCorePoolSize works
- What did you see instead?
nothing,it does not work.
2. Please tell us about your environment:
JDK8 & rocketmq-spring-boot-starter:2.2.3
3. Other information (e.g. detailed explanation, logs, related issues, suggestions how to fix, etc):
I am considering reuse RocketMQMessageListener#consumeThreadMax() property as consumeExecutor maximumSize,and consumeThreadNumber as coreSize.Will fix it.


Discussion:

Patch:
diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListener.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListener.java
index 36478645..302d276c 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListener.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/annotation/RocketMQMessageListener.java
@@ -17,12 +17,12 @@
 
 package org.apache.rocketmq.spring.annotation;
 
+import org.apache.rocketmq.client.impl.consumer.ConsumeMessageService;
 import java.lang.annotation.Documented;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-import java.util.concurrent.LinkedBlockingQueue;
 
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
@@ -73,12 +73,10 @@
 
     /**
      * Max consumer thread number.
-     * @deprecated This property is not work well, because the consumer thread pool executor use
-     * {@link LinkedBlockingQueue} with default capacity bound (Integer.MAX_VALUE), use
-     * {@link RocketMQMessageListener#consumeThreadNumber} .
-     * @see <a href="https://github.com/apache/rocketmq-spring/issues/429">issues#429</a>
+     * This property control consumer thread pool executor maximumPoolSize see
+     * {@link ConsumeMessageService#updateCorePoolSize(int)}
+     * @see <a href="https://github.com/apache/rocketmq-spring/issues/546">issues#546</a>
      */
-    @Deprecated
     int consumeThreadMax() default 64;
 
     /**
diff --git a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
index 0233a61a..910e9af0 100644
--- a/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
+++ b/rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainer.java
@@ -236,7 +236,7 @@ public void setRocketMQMessageListener(RocketMQMessageListener anno) {
         this.rocketMQMessageListener = anno;
 
         this.consumeMode = anno.consumeMode();
-        this.consumeThreadMax = anno.consumeThreadNumber();
+        this.consumeThreadMax = anno.consumeThreadMax();
         this.consumeThreadNumber = anno.consumeThreadNumber();
         this.messageModel = anno.messageModel();
         this.selectorType = anno.selectorType();
@@ -641,8 +641,8 @@ private void initRocketMQPushConsumer() throws MQClientException {
         if (accessChannel != null) {
             consumer.setAccessChannel(accessChannel);
         }
-        //set the consumer core thread number and maximum thread number has the same value
-        consumer.setConsumeThreadMax(consumeThreadNumber);
+
+        consumer.setConsumeThreadMax(consumeThreadMax);
         consumer.setConsumeThreadMin(consumeThreadNumber);
         consumer.setConsumeTimeout(consumeTimeout);
         consumer.setMaxReconsumeTimes(maxReconsumeTimes);


Test patch:
diff --git a/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainerTest.java b/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainerTest.java
index f7cd9cfb..de15fcdf 100644
--- a/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainerTest.java
+++ b/rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/support/DefaultRocketMQListenerContainerTest.java
@@ -244,7 +244,7 @@ public void testSetRocketMQMessageListener() {
         container.setRocketMQMessageListener(anno);
 
         assertEquals(anno.consumeMode(), container.getConsumeMode());
-        assertEquals(anno.consumeThreadNumber(), container.getConsumeThreadMax());
+        assertEquals(anno.consumeThreadMax(), container.getConsumeThreadMax());
         assertEquals(anno.consumeThreadNumber(), container.getConsumeThreadNumber());
         assertEquals(anno.messageModel(), container.getMessageModel());
         assertEquals(anno.selectorType(), container.getSelectorType());