You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/09/14 05:42:04 UTC
[GitHub] [incubator-eventmesh] Markliniubility opened a new pull request, #1264: Kafka
Markliniubility opened a new pull request, #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264
<!--
### Contribution Checklist
- Name the pull request in the form "[ISSUE #XXXX] Title of the pull request",
where *XXXX* should be replaced by the actual issue number.
Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
- Fill out the template below to describe the changes contributed by the pull request.
That will give reviewers the context they need to do the review.
- Each pull request should address only one issue.
Please do not mix up code from multiple issues.
- Each commit in the pull request should have a meaningful commit message.
- Once all items of the checklist are addressed, remove the above text and this checklist,
leaving only the filled out template below.
(The sections below can be removed for hotfixes of typos)
-->
<!--
(If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Cloese #<XXX>`.)
-->
Fixes #1262.
### Motivation
*Kafka Support for manual acknowledgement: the previous version of Kakfa Connector auto commits on consuming the messages*
### Modifications
*Disabled the auto-commit, and implemented the manual commit with updateOffset() API*
*Pick the largest offset from the list of cloudevent given, then commit to that specific offset*
### Documentation
- Does this pull request introduce a new feature?
- Yes
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
- Not yet documented
- If a feature is not applicable for documentation, explain why?
- Will be documented after completion of development
--
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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] xwm1992 merged pull request #1264: [ISSUE #1262] Kafka Support for manual acknowledgement
Posted by GitBox <gi...@apache.org>.
xwm1992 merged PR #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264
--
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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] Markliniubility commented on a diff in pull request #1264: [ISSUE #1262] Kafka Support for manual acknowledgement
Posted by GitBox <gi...@apache.org>.
Markliniubility commented on code in PR #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264#discussion_r973903035
##########
eventmesh-connector-plugin/eventmesh-connector-kafka/src/main/java/org/apache/eventmesh/connector/kafka/consumer/KafkaConsumerRunner.java:
##########
@@ -64,29 +72,33 @@ public void commit(EventMeshAction action) {
case CommitMessage:
// update offset
logger.info("message commit, topic: {}, current offset:{}", topicName,
- offset.get());
+ rec.offset());
break;
case ReconsumeLater:
// don't update offset
break;
case ManualAck:
// update offset
- offset.incrementAndGet();
logger
- .info("message ack, topic: {}, current offset:{}", topicName, offset.get());
+ .info("message ack, topic: {}, current offset:{}", topicName, rec.offset());
break;
default:
}
}
};
+ cloudEventToOffset.put(cloudEvent, rec.offset());
if (listener != null) {
listener.consume(cloudEvent, eventMeshAsyncConsumeContext);
}
});
}
} catch (WakeupException e) {
// Ignore exception if closing
- if (!closed.get()) throw e;
+ if (!closed.get()) {
Review Comment:
完成
--
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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] codecov[bot] commented on pull request #1264: [ISSUE #1262] Kafka Support for manual acknowledgement
Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264#issuecomment-1249057531
# [Codecov](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264?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 [#1264](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ab005d5) into [kafka-connector](https://codecov.io/gh/apache/incubator-eventmesh/commit/817dbd0f947eace3b798e80fadd08afd5c5ff3d1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (817dbd0) will **decrease** coverage by `0.12%`.
> The diff coverage is `0.00%`.
```diff
@@ Coverage Diff @@
## kafka-connector #1264 +/- ##
====================================================
- Coverage 8.43% 8.31% -0.13%
+ Complexity 533 524 -9
====================================================
Files 362 362
Lines 23245 23222 -23
Branches 2546 2537 -9
====================================================
- Hits 1960 1930 -30
- Misses 21134 21141 +7
Partials 151 151
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...re/protocol/http/processor/SubscribeProcessor.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvaHR0cC9wcm9jZXNzb3IvU3Vic2NyaWJlUHJvY2Vzc29yLmphdmE=) | `0.00% <ø> (ø)` | |
| [.../protocol/tcp/client/group/ClientGroupWrapper.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvdGNwL2NsaWVudC9ncm91cC9DbGllbnRHcm91cFdyYXBwZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...apache/eventmesh/common/file/WatchFileManager.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9maWxlL1dhdGNoRmlsZU1hbmFnZXIuamF2YQ==) | `32.35% <0.00%> (-35.30%)` | :arrow_down: |
| [...tandalone/broker/task/HistoryMessageClearTask.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1zdGFuZGFsb25lL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL3N0YW5kYWxvbmUvYnJva2VyL3Rhc2svSGlzdG9yeU1lc3NhZ2VDbGVhclRhc2suamF2YQ==) | `29.41% <0.00%> (-17.65%)` | :arrow_down: |
| [...mesh/connector/standalone/broker/MessageQueue.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLWNvbm5lY3Rvci1wbHVnaW4vZXZlbnRtZXNoLWNvbm5lY3Rvci1zdGFuZGFsb25lL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL3N0YW5kYWxvbmUvYnJva2VyL01lc3NhZ2VRdWV1ZS5qYXZh) | `32.46% <0.00%> (-7.80%)` | :arrow_down: |
| [...ava/org/apache/eventmesh/common/utils/IPUtils.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi91dGlscy9JUFV0aWxzLmphdmE=) | `33.33% <0.00%> (-6.49%)` | :arrow_down: |
| [...sh/client/grpc/consumer/EventMeshGrpcConsumer.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLXNkay1qYXZhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY2xpZW50L2dycGMvY29uc3VtZXIvRXZlbnRNZXNoR3JwY0NvbnN1bWVyLmphdmE=) | `75.80% <0.00%> (-1.62%)` | :arrow_down: |
| [...rg/apache/eventmesh/runtime/trace/LogExporter.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL3RyYWNlL0xvZ0V4cG9ydGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...core/protocol/http/consumer/EventMeshConsumer.java](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvaHR0cC9jb25zdW1lci9FdmVudE1lc2hDb25zdW1lci5qYXZh) | `0.00% <0.00%> (ø)` | |
| ... and [3 more](https://codecov.io/gh/apache/incubator-eventmesh/pull/1264/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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] Markliniubility commented on a diff in pull request #1264: [ISSUE #1262] Kafka Support for manual acknowledgement
Posted by GitBox <gi...@apache.org>.
Markliniubility commented on code in PR #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264#discussion_r973903399
##########
eventmesh-connector-plugin/eventmesh-connector-kafka/src/main/java/org/apache/eventmesh/connector/kafka/consumer/ConsumerImpl.java:
##########
@@ -108,9 +109,9 @@ public void subscribe(String topic) {
public void unsubscribe(String topic) {
try {
- // Get the current subscription
+ // Kafka will unsubscribe *all* topic if calling unsubscribe, so we
this.kafkaConsumer.unsubscribe();
- topicsSet.add(topic);
+ topicsSet.remove(topic);
Review Comment:
添加了`synchronized`保证线程安全
--
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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] githublaohu commented on a diff in pull request #1264: [ISSUE #1262] Kafka Support for manual acknowledgement
Posted by GitBox <gi...@apache.org>.
githublaohu commented on code in PR #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264#discussion_r973506693
##########
eventmesh-connector-plugin/eventmesh-connector-kafka/src/main/java/org/apache/eventmesh/connector/kafka/consumer/KafkaConsumerRunner.java:
##########
@@ -37,22 +39,28 @@ public class KafkaConsumerRunner implements Runnable {
private final Logger logger = LoggerFactory.getLogger(KafkaConsumerRunner.class);
private final AtomicBoolean closed = new AtomicBoolean(false);
private final KafkaConsumer<String, CloudEvent> consumer;
+ private Map<CloudEvent, Long> cloudEventToOffset;
private EventListener listener;
private AtomicInteger offset;
public KafkaConsumerRunner(KafkaConsumer<String, CloudEvent> kafkaConsumer) {
this.consumer = kafkaConsumer;
+ cloudEventToOffset = new HashMap<>();
}
- public void setListener(EventListener listener) {
+ public synchronized void setListener(EventListener listener) {
this.listener = listener;
}
+ public long getOffset(CloudEvent cloudEvent) {
+ return cloudEventToOffset.getOrDefault(cloudEvent, 0L);
+ }
+
@Override
public void run() {
Review Comment:
如果这个线程是一直执行,请保证异常情况下不退出线程
##########
eventmesh-connector-plugin/eventmesh-connector-kafka/src/main/java/org/apache/eventmesh/connector/kafka/consumer/KafkaConsumerRunner.java:
##########
@@ -37,22 +39,28 @@ public class KafkaConsumerRunner implements Runnable {
private final Logger logger = LoggerFactory.getLogger(KafkaConsumerRunner.class);
private final AtomicBoolean closed = new AtomicBoolean(false);
private final KafkaConsumer<String, CloudEvent> consumer;
+ private Map<CloudEvent, Long> cloudEventToOffset;
private EventListener listener;
private AtomicInteger offset;
public KafkaConsumerRunner(KafkaConsumer<String, CloudEvent> kafkaConsumer) {
this.consumer = kafkaConsumer;
+ cloudEventToOffset = new HashMap<>();
}
- public void setListener(EventListener listener) {
+ public synchronized void setListener(EventListener listener) {
this.listener = listener;
}
+ public long getOffset(CloudEvent cloudEvent) {
+ return cloudEventToOffset.getOrDefault(cloudEvent, 0L);
+ }
+
@Override
public void run() {
- try {
+ try { // TODO: change it to manual ack
while (!closed.get()) {
Review Comment:
1. while里面加入一个try catch,catch里面打印日志就了
2. 在 forEach里面也加入一个try cath,一个消息报错。整个list就不执行了。这样不行吧
##########
eventmesh-connector-plugin/eventmesh-connector-kafka/src/main/java/org/apache/eventmesh/connector/kafka/consumer/KafkaConsumerRunner.java:
##########
@@ -64,29 +72,33 @@ public void commit(EventMeshAction action) {
case CommitMessage:
// update offset
logger.info("message commit, topic: {}, current offset:{}", topicName,
- offset.get());
+ rec.offset());
break;
case ReconsumeLater:
// don't update offset
break;
case ManualAck:
// update offset
- offset.incrementAndGet();
logger
- .info("message ack, topic: {}, current offset:{}", topicName, offset.get());
+ .info("message ack, topic: {}, current offset:{}", topicName, rec.offset());
break;
default:
}
}
};
+ cloudEventToOffset.put(cloudEvent, rec.offset());
if (listener != null) {
listener.consume(cloudEvent, eventMeshAsyncConsumeContext);
}
});
}
} catch (WakeupException e) {
// Ignore exception if closing
- if (!closed.get()) throw e;
+ if (!closed.get()) {
Review Comment:
感觉没有意义,closed会在while识别。
--
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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
[GitHub] [incubator-eventmesh] githublaohu commented on a diff in pull request #1264: [ISSUE #1262] Kafka Support for manual acknowledgement
Posted by GitBox <gi...@apache.org>.
githublaohu commented on code in PR #1264:
URL: https://github.com/apache/incubator-eventmesh/pull/1264#discussion_r973507433
##########
eventmesh-connector-plugin/eventmesh-connector-kafka/src/main/java/org/apache/eventmesh/connector/kafka/consumer/ConsumerImpl.java:
##########
@@ -108,9 +109,9 @@ public void subscribe(String topic) {
public void unsubscribe(String topic) {
try {
- // Get the current subscription
+ // Kafka will unsubscribe *all* topic if calling unsubscribe, so we
this.kafkaConsumer.unsubscribe();
- topicsSet.add(topic);
+ topicsSet.remove(topic);
Review Comment:
HashSet不是线程安全的,请保证topics.remove(),与115是线程安全的
--
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@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org