You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/08/22 03:32:36 UTC

[GitHub] [rocketmq-flink] duhenglucky commented on a diff in pull request #50: Supports the 'startMessageOffset' option for RocketMQSourceFunction

duhenglucky commented on code in PR #50:
URL: https://github.com/apache/rocketmq-flink/pull/50#discussion_r950984137


##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -357,32 +361,37 @@ private long getMessageQueueOffset(MessageQueue mq) throws MQClientException {
         // restoredOffsets(unionOffsetStates) is the restored global union state;
         // should only snapshot mqs that actually belong to us
         if (offset == null) {
-            // fetchConsumeOffset from broker
-            offset = consumer.fetchConsumeOffset(mq, false);
-            if (!restored || offset < 0) {
-                String initialOffset =
-                        props.getProperty(
-                                RocketMQConfig.CONSUMER_OFFSET_RESET_TO, CONSUMER_OFFSET_LATEST);
-                switch (initialOffset) {
-                    case CONSUMER_OFFSET_EARLIEST:
-                        offset = consumer.minOffset(mq);
-                        break;
-                    case CONSUMER_OFFSET_LATEST:
-                        offset = consumer.maxOffset(mq);
-                        break;
-                    case CONSUMER_OFFSET_TIMESTAMP:
-                        offset =
-                                consumer.searchOffset(
-                                        mq,
-                                        getLong(
-                                                props,
-                                                RocketMQConfig.CONSUMER_OFFSET_FROM_TIMESTAMP,
-                                                System.currentTimeMillis()));
-                        break;
-                    default:
-                        throw new IllegalArgumentException(
-                                "Unknown value for CONSUMER_OFFSET_RESET_TO.");
+            if (startMessageOffset == OPTIONAL_START_MESSAGE_OFFSET.defaultValue()) {

Review Comment:
   Minimize iteration depth



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org