[
https://issues.apache.org/jira/browse/ROCKETMQ-102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15898787#comment-15898787
]
ASF GitHub Bot commented on ROCKETMQ-102:
-----------------------------------------
Github user Jaskey commented on a diff in the pull request:
https://github.com/apache/incubator-rocketmq/pull/64#discussion_r104592589
--- Diff:
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
---
@@ -92,10 +92,22 @@ public void run() {
}
}
- public void shutdown() {
+ @Override
+ public void shutdown(long awaitTerminateMillis) {
this.stopped = true;
this.scheduledExecutorService.shutdown();
this.consumeExecutor.shutdown();
+ //await to consume
+ if (awaitTerminateMillis > 0) {
+ try {
+
this.consumeExecutor.awaitTermination(awaitTerminateMillis,TimeUnit.MILLISECONDS);
+ if (!this.consumeExecutor.isTerminated()) log.info("There
are messages still being consumed in thread pool, but not going to await them
anymore. Have awaited for {} ms",awaitTerminateMillis);
--- End diff --
@zhouxinyu In my option, rocketmq should have no right to interrupt what
dev's business are doing, we may be doing some time-cost job which are doing
transcation or inserting database, we should leave the task running if executor
is still not terminated.
Besides, since the old version has not termination millis, so 0 of
termination millis is the default behavior , shutdown now will cost task being
interrupt/cancel immediately which is not proper in my opinion.
I have updated the pr , but still using my old method, please review and
let's discuss more about it.
> When shutdown(), the persisted offet is not the latest consumed message,
> which may cause repeated messages
> ----------------------------------------------------------------------------------------------------------
>
> Key: ROCKETMQ-102
> URL: https://issues.apache.org/jira/browse/ROCKETMQ-102
> Project: Apache RocketMQ
> Issue Type: Improvement
> Components: rocketmq-client
> Reporter: Jaskey Lam
> Assignee: Xiaorui Wang
>
> When shutdown push consumer, push consumer will shutdwon thread pool then
> persist offset.
> While shutdown thread pool is only stop submiting message to consume, which
> does not stop consuming message which exists in the the thread queue or is
> already being consumed.
> Which will cause repeated message very easily though user are shutdown
> gracefully according to the provided interface.
> A way to solve this problem is needed. Such as accpet a param that how long
> to wait for thread pool to terminated.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)