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/07/24 15:02:45 UTC
[GitHub] [rocketmq-flink] yiduwangkai opened a new pull request, #46: [upgrade consumer api]Use litePullConsumer model instead of default p…
yiduwangkai opened a new pull request, #46:
URL: https://github.com/apache/rocketmq-flink/pull/46
Use DefaultlitePullConsumer model instead of default pull consumer
Tips
Thank you very much for contributing to Apache rocketmq-flink.
What is the purpose of the pull request
*solve some code about using defaultPullConsumer api
Brief change log
(for example:)
*Modify
RocketMQConfig.java
RocketMQSourceFunction.java
RocketMQSourceEnumerator.java
RocketMQPartitionSplitReader.java
RocketMQSourceTest.java
--
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
[GitHub] [rocketmq-flink] zhouxinyu commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r992071000
##########
src/main/java/org/apache/rocketmq/flink/source/reader/RocketMQPartitionSplitReader.java:
##########
@@ -120,9 +119,14 @@ public RocketMQPartitionSplitReader(
public RecordsWithSplitIds<Tuple3<T, Long, Long>> fetch() throws IOException {
RocketMQPartitionSplitRecords<Tuple3<T, Long, Long>> recordsBySplits =
new RocketMQPartitionSplitRecords<>();
- Set<MessageQueue> messageQueues;
+ Collection<MessageQueue> messageQueues;
try {
- messageQueues = consumer.fetchSubscribeMessageQueues(topic);
+ messageQueues = consumer.fetchMessageQueues(topic);
+ if (StringUtils.isNotEmpty(sql)) {
+ consumer.subscribe(topic, MessageSelector.bySql(sql));
Review Comment:
Will the `fetch` method be called frequently? There may be some performance issues if so, since `subscribe` is a heavy method.
--
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
[GitHub] [rocketmq-flink] codecov-commenter commented on pull request #46: [ISSUE #35]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#issuecomment-1229470154
# [Codecov](https://codecov.io/gh/apache/rocketmq-flink/pull/46?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#46](https://codecov.io/gh/apache/rocketmq-flink/pull/46?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (afbbea4) into [main](https://codecov.io/gh/apache/rocketmq-flink/commit/b7c00f3ea71b7145e6ad28c7f71b0eb507adb332?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b7c00f3) will **increase** coverage by `0.29%`.
> The diff coverage is `0.00%`.
```diff
@@ Coverage Diff @@
## main #46 +/- ##
============================================
+ Coverage 27.14% 27.44% +0.29%
Complexity 149 149
============================================
Files 59 59
Lines 2424 2394 -30
Branches 258 252 -6
============================================
- Hits 658 657 -1
+ Misses 1701 1672 -29
Partials 65 65
```
| [Impacted Files](https://codecov.io/gh/apache/rocketmq-flink/pull/46?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...g/apache/rocketmq/flink/legacy/RocketMQConfig.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL2xlZ2FjeS9Sb2NrZXRNUUNvbmZpZy5qYXZh) | `0.00% <ø> (ø)` | |
| [.../rocketmq/flink/legacy/RocketMQSourceFunction.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL2xlZ2FjeS9Sb2NrZXRNUVNvdXJjZUZ1bmN0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...nk/source/enumerator/RocketMQSourceEnumerator.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL3NvdXJjZS9lbnVtZXJhdG9yL1JvY2tldE1RU291cmNlRW51bWVyYXRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...nk/source/reader/RocketMQPartitionSplitReader.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL3NvdXJjZS9yZWFkZXIvUm9ja2V0TVFQYXJ0aXRpb25TcGxpdFJlYWRlci5qYXZh) | `0.00% <ø> (ø)` | |
| [...ource/table/RocketMQDynamicTableSourceFactory.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL3NvdXJjZS90YWJsZS9Sb2NrZXRNUUR5bmFtaWNUYWJsZVNvdXJjZUZhY3RvcnkuamF2YQ==) | `73.91% <0.00%> (-0.38%)` | :arrow_down: |
| [...org/apache/rocketmq/flink/legacy/RocketMQSink.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL2xlZ2FjeS9Sb2NrZXRNUVNpbmsuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...cketmq/flink/legacy/common/util/RocketMQUtils.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL2xlZ2FjeS9jb21tb24vdXRpbC9Sb2NrZXRNUVV0aWxzLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...mq/flink/source/table/RocketMQScanTableSource.java](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL2ZsaW5rL3NvdXJjZS90YWJsZS9Sb2NrZXRNUVNjYW5UYWJsZVNvdXJjZS5qYXZh) | `24.65% <0.00%> (+0.33%)` | :arrow_up: |
| ... and [1 more](https://codecov.io/gh/apache/rocketmq-flink/pull/46/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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
[GitHub] [rocketmq-flink] keranbingaa commented on a diff in pull request #46: [upgrade consumer api]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
keranbingaa commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r934626417
##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -241,91 +243,58 @@ public void run(SourceContext context) throws Exception {
() -> {
while (runningChecker.isRunning()) {
try {
- long offset = getMessageQueueOffset(mq);
-
- PullResult pullResult = null;
+ getMessageQueueOffset(mq);
if (StringUtils.isEmpty(sql)) {
- pullResult =
- consumer.pullBlockIfNotFound(
- mq, tag, offset, pullBatchSize);
+ consumer.subscribe(topic, tag);
Review Comment:
this can be put out of the while loop
--
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
[GitHub] [rocketmq-flink] SteNicholas commented on a diff in pull request #46: [ISSUE #35]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r990724567
##########
src/main/java/org/apache/rocketmq/flink/source/reader/RocketMQPartitionSplitReader.java:
##########
@@ -75,6 +70,8 @@
private final long startTime;
private final long startOffset;
+ private final int pollTime;
Review Comment:
```suggestion
private final long pollTime;
```
##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -404,8 +380,7 @@ private long getMessageQueueOffset(MessageQueue mq) throws MQClientException {
private void updateMessageQueueOffset(MessageQueue mq, long offset) throws MQClientException {
offsetTable.put(mq, offset);
if (!enableCheckpoint) {
- consumer.updateConsumeOffset(mq, offset);
- consumer.getOffsetStore().persist(consumer.queueWithNamespace(mq));
+ consumer.getOffsetStore().updateOffset(mq, offset, false);
Review Comment:
Why not persist the offset? IMO, the offset should be persisted here. cc @ShannonDing @zhouxinyu
--
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
[GitHub] [rocketmq-flink] SteNicholas merged pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
SteNicholas merged PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq-flink] yiduwangkai commented on pull request #46: [ISSUE #35]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#issuecomment-1236381122
>
ok
--
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
[GitHub] [rocketmq-flink] zhouxinyu commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r992057758
##########
src/main/java/org/apache/rocketmq/flink/source/enumerator/RocketMQSourceEnumerator.java:
##########
@@ -337,16 +339,16 @@ private long getOffsetByMessageQueue(MessageQueue mq) throws MQClientException {
} else {
switch (consumerOffsetMode) {
case CONSUMER_OFFSET_EARLIEST:
- offset = consumer.minOffset(mq);
- break;
+ consumer.seekToBegin(mq);
+ return -1;
case CONSUMER_OFFSET_LATEST:
- offset = consumer.maxOffset(mq);
- break;
+ consumer.seekToEnd(mq);
+ return -1;
Review Comment:
Return directly with -1, this is a different behavior compared to the old version or `CONSUMER_OFFSET_TIMESTAMP`.
It's recommended to unify the behavior.
--
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
[GitHub] [rocketmq-flink] yiduwangkai commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r1003972794
##########
src/main/java/org/apache/rocketmq/flink/source/reader/RocketMQPartitionSplitReader.java:
##########
@@ -173,25 +177,28 @@ public RecordsWithSplitIds<Tuple3<T, Long, Long>> fetch() throws IOException {
recordsBySplits.prepareForRead();
return recordsBySplits;
}
- if (StringUtils.isNotEmpty(sql)) {
- pullResult =
- consumer.pull(
- messageQueue,
- MessageSelector.bySql(sql),
- messageOffset,
- MAX_MESSAGE_NUMBER_PER_BLOCK);
- } else {
- pullResult =
- consumer.pull(
- messageQueue,
- tag,
- messageOffset,
- MAX_MESSAGE_NUMBER_PER_BLOCK);
- }
- } catch (MQClientException
- | RemotingException
- | MQBrokerException
- | InterruptedException e) {
+ consumer.assign(Collections.singletonList(messageQueue));
Review Comment:
actually, seek method is enough,i will remove assign code
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq-flink] yiduwangkai commented on a diff in pull request #46: [ISSUE #35]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r946821892
##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -241,91 +243,58 @@ public void run(SourceContext context) throws Exception {
() -> {
while (runningChecker.isRunning()) {
try {
- long offset = getMessageQueueOffset(mq);
-
- PullResult pullResult = null;
+ getMessageQueueOffset(mq);
if (StringUtils.isEmpty(sql)) {
- pullResult =
- consumer.pullBlockIfNotFound(
- mq, tag, offset, pullBatchSize);
+ consumer.subscribe(topic, tag);
Review Comment:
ok
--
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
[GitHub] [rocketmq-flink] yiduwangkai commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r1003938033
##########
src/main/java/org/apache/rocketmq/flink/source/reader/RocketMQPartitionSplitReader.java:
##########
@@ -120,9 +119,14 @@ public RocketMQPartitionSplitReader(
public RecordsWithSplitIds<Tuple3<T, Long, Long>> fetch() throws IOException {
RocketMQPartitionSplitRecords<Tuple3<T, Long, Long>> recordsBySplits =
new RocketMQPartitionSplitRecords<>();
- Set<MessageQueue> messageQueues;
+ Collection<MessageQueue> messageQueues;
try {
- messageQueues = consumer.fetchSubscribeMessageQueues(topic);
+ messageQueues = consumer.fetchMessageQueues(topic);
+ if (StringUtils.isNotEmpty(sql)) {
+ consumer.subscribe(topic, MessageSelector.bySql(sql));
Review Comment:
ok, i have reoptimized the code
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq-flink] SteNicholas commented on pull request #46: [ISSUE #35]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#issuecomment-1231013168
Thanks for @yiduwangkai updates. Could you please resolve the conflicts?
--
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
[GitHub] [rocketmq-flink] SteNicholas commented on a diff in pull request #46: [ISSUE #35]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r946305414
##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -241,91 +243,58 @@ public void run(SourceContext context) throws Exception {
() -> {
while (runningChecker.isRunning()) {
try {
- long offset = getMessageQueueOffset(mq);
-
- PullResult pullResult = null;
+ getMessageQueueOffset(mq);
if (StringUtils.isEmpty(sql)) {
- pullResult =
- consumer.pullBlockIfNotFound(
- mq, tag, offset, pullBatchSize);
+ consumer.subscribe(topic, tag);
Review Comment:
I agree with @keranbingaa. The `consumer.subscribe(topic, tag)` could be move to the while loop.
##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -241,91 +243,58 @@ public void run(SourceContext context) throws Exception {
() -> {
while (runningChecker.isRunning()) {
try {
- long offset = getMessageQueueOffset(mq);
-
- PullResult pullResult = null;
+ getMessageQueueOffset(mq);
if (StringUtils.isEmpty(sql)) {
- pullResult =
- consumer.pullBlockIfNotFound(
- mq, tag, offset, pullBatchSize);
+ consumer.subscribe(topic, tag);
} else {
// pull with sql do not support block pull.
- pullResult =
- consumer.pull(
- mq,
- MessageSelector.bySql(sql),
- offset,
- pullBatchSize);
+ consumer.subscribe(
+ topic, MessageSelector.bySql(sql));
}
+ consumer.setPullBatchSize(pullBatchSize);
+ // consumer.seek(mq, offset);
boolean found = false;
- switch (pullResult.getPullStatus()) {
- case FOUND:
- List<MessageExt> messages =
- pullResult.getMsgFoundList();
- for (MessageExt msg : messages) {
- byte[] key =
- msg.getKeys() != null
- ? msg.getKeys()
- .getBytes(
- StandardCharsets
- .UTF_8)
- : null;
- byte[] value = msg.getBody();
- OUT data =
- schema.deserializeKeyAndValue(
- key, value);
-
- // output and state update are atomic
- synchronized (checkPointLock) {
- log.debug(
- msg.getMsgId()
- + "_"
- + msg
- .getBrokerName()
- + " "
- + msg.getQueueId()
- + " "
- + msg
- .getQueueOffset());
- context.collectWithTimestamp(
- data,
- msg.getBornTimestamp());
-
- // update max eventTime per queue
- // waterMarkPerQueue.extractTimestamp(mq, msg.getBornTimestamp());
- waterMarkForAll.extractTimestamp(
- msg.getBornTimestamp());
- tpsMetric.markEvent();
- }
+ List<MessageExt> messages = consumer.poll();
Review Comment:
This need to use `poll(timeout)` to avoid blocking the message consumer.
--
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
[GitHub] [rocketmq-flink] yiduwangkai commented on pull request #46: [upgrade consumer api]Use litePullConsumer model instead of default p…
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#issuecomment-1193460197
there are some problems about this code, like home to Use defaultlitPullConsumer to get offset and perform offset self-management
--
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
[GitHub] [rocketmq-flink] zhouxinyu commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r992074796
##########
src/main/java/org/apache/rocketmq/flink/source/reader/RocketMQPartitionSplitReader.java:
##########
@@ -173,25 +177,28 @@ public RecordsWithSplitIds<Tuple3<T, Long, Long>> fetch() throws IOException {
recordsBySplits.prepareForRead();
return recordsBySplits;
}
- if (StringUtils.isNotEmpty(sql)) {
- pullResult =
- consumer.pull(
- messageQueue,
- MessageSelector.bySql(sql),
- messageOffset,
- MAX_MESSAGE_NUMBER_PER_BLOCK);
- } else {
- pullResult =
- consumer.pull(
- messageQueue,
- tag,
- messageOffset,
- MAX_MESSAGE_NUMBER_PER_BLOCK);
- }
- } catch (MQClientException
- | RemotingException
- | MQBrokerException
- | InterruptedException e) {
+ consumer.assign(Collections.singletonList(messageQueue));
Review Comment:
The same issue. It would be better if we handle the subscription and assignment asynchronously rather than in a `fetch` call.
--
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
[GitHub] [rocketmq-flink] yiduwangkai commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r1002666864
##########
src/main/java/org/apache/rocketmq/flink/source/enumerator/RocketMQSourceEnumerator.java:
##########
@@ -337,16 +339,16 @@ private long getOffsetByMessageQueue(MessageQueue mq) throws MQClientException {
} else {
switch (consumerOffsetMode) {
case CONSUMER_OFFSET_EARLIEST:
- offset = consumer.minOffset(mq);
- break;
+ consumer.seekToBegin(mq);
+ return -1;
case CONSUMER_OFFSET_LATEST:
- offset = consumer.maxOffset(mq);
- break;
+ consumer.seekToEnd(mq);
+ return -1;
Review Comment:
new api can not get the offset, when set maxoffset or minoffset
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq-flink] yiduwangkai commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r1002666864
##########
src/main/java/org/apache/rocketmq/flink/source/enumerator/RocketMQSourceEnumerator.java:
##########
@@ -337,16 +339,16 @@ private long getOffsetByMessageQueue(MessageQueue mq) throws MQClientException {
} else {
switch (consumerOffsetMode) {
case CONSUMER_OFFSET_EARLIEST:
- offset = consumer.minOffset(mq);
- break;
+ consumer.seekToBegin(mq);
+ return -1;
case CONSUMER_OFFSET_LATEST:
- offset = consumer.maxOffset(mq);
- break;
+ consumer.seekToEnd(mq);
+ return -1;
Review Comment:
new api can not get the offset, when set maxoffset or minoffset
or After the offset is set, using this api get offset
`consumer.seekToEnd(mq);
long offset = consumer.committed(mq);`
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq-flink] zhouxinyu commented on pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#issuecomment-1291794640
Since not all broker versions support lite pull, we need to clarify it in our doc.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq-flink] zhouxinyu commented on a diff in pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on code in PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#discussion_r992088138
##########
src/main/java/org/apache/rocketmq/flink/legacy/RocketMQSourceFunction.java:
##########
@@ -404,8 +380,7 @@ private long getMessageQueueOffset(MessageQueue mq) throws MQClientException {
private void updateMessageQueueOffset(MessageQueue mq, long offset) throws MQClientException {
offsetTable.put(mq, offset);
if (!enableCheckpoint) {
- consumer.updateConsumeOffset(mq, offset);
- consumer.getOffsetStore().persist(consumer.queueWithNamespace(mq));
+ consumer.getOffsetStore().updateOffset(mq, offset, false);
Review Comment:
It depends. The consumer will persist the offsets periodically, even if we only call `updateOffset`. The `persist` call is heavy, each call will trigger a RPC.
So, if the updateMessageQueueOffset already batched some requests, `persist` is more suitable. If not and we can tolerate redundant messages in some abnormal cases, updateOffset is enough.
--
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
[GitHub] [rocketmq-flink] zhouxinyu commented on pull request #46: [#35] Use `LitePullConsumer` model instead of default pull consumer
Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on PR #46:
URL: https://github.com/apache/rocketmq-flink/pull/46#issuecomment-1274399313
Thanks, @yiduwangkai for your contributions. I left some comments, but I'm not familiar with rocketmq-flink, so please @SteNicholas help have a look.
--
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