rocketmq icon indicating copy to clipboard operation
rocketmq copied to clipboard

consumeThreadMax is useless in ConsumeMessageConcurrentlyService

Open coder-zzzz opened this issue 3 years ago • 3 comments

 public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
        MessageListenerConcurrently messageListener) {
        this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
        this.messageListener = messageListener;

        this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
        this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
        this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

        this.consumeExecutor = new ThreadPoolExecutor(
            this.defaultMQPushConsumer.getConsumeThreadMin(),
            this.defaultMQPushConsumer.getConsumeThreadMax(),
            1000 * 60,
            TimeUnit.MILLISECONDS,
            this.consumeRequestQueue,
            new ThreadFactoryImpl("ConsumeMessageThread_"));

        this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
        this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
    }

See the code above, the consumeExecutor use a default capacity(Int.MaxValue) LinkedBlockingQueue.If there is more than getConsumeThreadMin thread is working ,then new task will put in the queue, will never create new thread to process new task.

coder-zzzz avatar Sep 02 '21 09:09 coder-zzzz

so, what is your opinion?

odbozhou avatar Sep 03 '21 02:09 odbozhou

so, what is your opinion?

use one property like 'consumeThreadNum' instead of the consumeThreadMin and consumeThreadMax

coder-zzzz avatar Sep 03 '21 03:09 coder-zzzz

@coder-zzzz Could you submit a PR to fix it? I think consumeThreadNum can be added , consumeThreadMin consumeThreadMax can be left for compatibility and be declared as deprecated.

caigy avatar Sep 15 '21 02:09 caigy